【问题标题】:Storage Account Issues?存储帐户问题?
【发布时间】:2015-06-02 17:00:54
【问题描述】:

我正在尝试创建一个存储组,但遇到了一些问题。

这是我正在使用的代码:

$StorageAccountName = 'myazurefileshare'
$Share              = 'FileShare'
$Location           = 'North Europe'
$ac = Get-AzureStorageAccount -StorageAccountName $StorageAccountName -ErrorAction SilentlyContinue
"Storage account exists? [$(if ($ac) {$true} else {$false})]"
If (!$ac)  # Does not exist - so create it
   {
     Write-Verbose "Storage Account [$StorageAccountName] in [$Location] does not exist"
     Write-Verbose "Creating Storage Account [$StorageAccountName] in [$Location]"
     New-AzureStorageAccount -StorageAccountName $StorageAccountName `
        -Location $Location -type 'Standard_GRS'
   }

如果我在详细的情况下运行它,我会得到:

VERBOSE: 19:58:11 - Begin Operation: Get-AzureStorageAccount
VERBOSE: 19:58:12 - Completed Operation: Get-AzureStorageAccount
Storage account exists? [False]
VERBOSE: Storage Account [myazurefileshare] in [North Europe] does not exist
VERBOSE: Creating Storage Account [myazurefileshare] in [North Europe]
VERBOSE: 19:58:12 - Begin Operation: New-AzureStorageAccount
New-AzureStorageAccount : ConflictError: The storage account named 'myazurefileshare' is already taken.
At line:13 char:6
+      New-AzureStorageAccount -StorageAccountName $StorageAccountName  ...
+      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureStorageAccount], CloudException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.StorageServices.NewAzureStorageAccountCommand

VERBOSE: 19:58:14 - Completed Operation: New-AzureStorageAccount

所以 - 当我执行 Get-AzureStorageAccount 时,它告诉我存储帐户不存在。但是当我尝试创建它时,它会因为名称存在而失败。不用说,Test-AzureName 和返回的错误是一致的:

C:> Test-AzureName -Storage myazurefileshare
VERBOSE: The storage account named 'myazurefileshare' is already taken.
True

那么为什么 Get-AzureStorageAccount 不返回 Test-Azurename 说存在的实际存储帐户?

线索?

(对于之前的格式问题,我们深表歉意!)

【问题讨论】:

  • 如果我没记错的话,Get-AzureStorageAccount 会尝试在您的订阅中查找存储帐户,而 Test-AzurenameNew-AzureStorageAccount 在全局上下文中运行以检查名称的可用性。因此,如果您尝试创建的存储帐户是由其他人创建但不在您的订阅中,Get-AzureStorageAccount 将返回 null 但 Test-AzurenameNew-AzureStorageAccount 将失败。
  • 我刚刚弄清楚发生了什么 - 你是对的。我试图使用的名字被其他人使用。我现在有那部分代码工作得很好谢谢!

标签: azure azure-storage


【解决方案1】:

存储帐户名称在订阅中是唯一的。当您尝试列出具有给定名称的帐户时,在您的订阅下找不到该帐户,但已被其他人占用,并且不允许您创建另一个具有相同名称的存储帐户。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-12
    • 1970-01-01
    • 2021-06-07
    • 1970-01-01
    • 1970-01-01
    • 2013-10-10
    • 2021-01-31
    相关资源
    最近更新 更多