我无法在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>'
答案 0 :(得分:1)
首先,您需要通过执行:
来要求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。