fog-azure-rm:创建磁盘失败,常量未初始化 Azure::Core
fog-azure-rm: creating Disks fails with uninitialized constant Azure::Core
我无法在 Azure 中创建磁盘。以下是我创建的步骤,但它失败了。
版本:
fog-azure-rm (0.3.2)
ruby 版本 2.4.0
azure_storage_service = Fog::Storage::AzureRM.new(
:tenant_id => '<Tenantid>',
:client_id => '<Clientid>',
:client_secret => '<ClientSecret>',
:subscription_id => '<Subscriptionid>'
)
azure_storage_service.create_disk('disk_name',1023)
/usr/local/lib/ruby/gems/2.4.0/gems/fog-azure-rm-0.3.2/lib/fog/azurerm/requests/storage/create_page_blob.rb:13:in `rescue in create_page_blob': uninitialized constant Azure::Core (NameError)
from /usr/local/lib/ruby/gems/2.4.0/gems/fog-azure-rm-0.3.2/lib/fog/azurerm/requests/storage/create_page_blob.rb:11:in `create_page_blob'
from /usr/local/lib/ruby/gems/2.4.0/gems/fog-azure-rm-0.3.2/lib/fog/azurerm/requests/storage/create_disk.rb:37:in `create_disk'
from createDisk.rb:12:in `<main>'
首先,您需要通过执行以下命令来获取 Fog 库:
require 'fog/azurerm'
接下来,如果您使用现有的存储帐户,请将存储帐户和密钥添加到连接中。如果我从我的代码中删除它们,我会得到与您相同的错误日志。以下代码对我有用。请将 * 替换为您的值。
require 'fog/azurerm'
azure_storage_service = Fog::Storage.new(
:provider => 'AzureRM',
:tenant_id => '*****', # Tenant id of Azure Active Directory Application
:client_id => '*****************', # Client id of Azure Active Directory Application
:client_secret => '************', # Client Secret of Azure Active Directory Application
:subscription_id => '***************', # Subscription id of an Azure Account
:azure_storage_account_name => 'shuiwindiag907', # Name of an Azure Storage Account
:azure_storage_access_key => '************************', # Key of an Azure Storage Account
:environment => 'AzureCloud' # Azure cloud environment. Default is AzureCloud.
)
azure_storage_service.create_disk('shui_test',5) ##By default the disk will be created in the container 'vhds'. If the container does not exist, please create it or set options[:container_name].
更多信息请参考此link。
我无法在 Azure 中创建磁盘。以下是我创建的步骤,但它失败了。
版本:
fog-azure-rm (0.3.2)
ruby 版本 2.4.0
azure_storage_service = Fog::Storage::AzureRM.new(
:tenant_id => '<Tenantid>',
:client_id => '<Clientid>',
:client_secret => '<ClientSecret>',
:subscription_id => '<Subscriptionid>'
)
azure_storage_service.create_disk('disk_name',1023)
/usr/local/lib/ruby/gems/2.4.0/gems/fog-azure-rm-0.3.2/lib/fog/azurerm/requests/storage/create_page_blob.rb:13:in `rescue in create_page_blob': uninitialized constant Azure::Core (NameError)
from /usr/local/lib/ruby/gems/2.4.0/gems/fog-azure-rm-0.3.2/lib/fog/azurerm/requests/storage/create_page_blob.rb:11:in `create_page_blob'
from /usr/local/lib/ruby/gems/2.4.0/gems/fog-azure-rm-0.3.2/lib/fog/azurerm/requests/storage/create_disk.rb:37:in `create_disk'
from createDisk.rb:12:in `<main>'
首先,您需要通过执行以下命令来获取 Fog 库:
require 'fog/azurerm'
接下来,如果您使用现有的存储帐户,请将存储帐户和密钥添加到连接中。如果我从我的代码中删除它们,我会得到与您相同的错误日志。以下代码对我有用。请将 * 替换为您的值。
require 'fog/azurerm'
azure_storage_service = Fog::Storage.new(
:provider => 'AzureRM',
:tenant_id => '*****', # Tenant id of Azure Active Directory Application
:client_id => '*****************', # Client id of Azure Active Directory Application
:client_secret => '************', # Client Secret of Azure Active Directory Application
:subscription_id => '***************', # Subscription id of an Azure Account
:azure_storage_account_name => 'shuiwindiag907', # Name of an Azure Storage Account
:azure_storage_access_key => '************************', # Key of an Azure Storage Account
:environment => 'AzureCloud' # Azure cloud environment. Default is AzureCloud.
)
azure_storage_service.create_disk('shui_test',5) ##By default the disk will be created in the container 'vhds'. If the container does not exist, please create it or set options[:container_name].
更多信息请参考此link。