Remote name could not be resolved - Azure PowerShell Containers

Hello, everyone!

I've been getting PowerShell errors since last Thursday whenever I attempt to create a regular storage container in a storage account.

New-AzureStorageContainer : The remote name could not be resolved: 'microsoft.windowsazure.commands.servicemanagement.m
odel.storageservicepropertiesoperationcontext.blob.core.windows.net'
At C:\TestLab.ps1:141 char:10
+     else{New-AzureStorageContainer -Name ($VMName).ToLower() -Con ...
+          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureStorageContainer], StorageException
    + FullyQualifiedErrorId : StorageException,Microsoft.WindowsAzure.Commands.Storage.Blob.Cmdlet.NewAzureStorageCont 
   ainerCommand

The storage account creates ok, I can obtain my storage context just fine. If I create these containers in the Portal, everything works well. I can manipulate the containers just fine if they're created in the portal.

The exact command I'm using is:

if(Get-AzureStorageContainer -Name ($VMName).ToLower() -Context $StorageContext -ErrorAction SilentlyContinue){"$VMName Container Exists"}
    else{New-AzureStorageContainer -Name ($VMName).ToLower() -Context $StorageContext}



  • Edited by BMOT1 Monday, August 31, 2015 2:58 PM
August 31st, 2015 2:57pm

Resolved!

I caught my mistake. It was in the context. I'll summarize here in case anyone else has this issue.

Here's how I built my context originally:

$StorageAcct = Get-AzureStorageAccount -StorageAccountName $StorageAcctName
$StorageKey =(Get-AzureStorageKey -StorageAccountName $StorageAcct.Label).Primary
$StorageContext = New-AzureStorageContext -StorageAccountName $StorageAcct -StorageAccountKey $StorageKey

What you'll notice is that my storage account has been stored as a variable. When I create my storage key, I specify the label attribute of the storage account as the storage account name given to -StorageAccountName

"$storagekey= (Get-AzureStorageKey -StorageAccountName $StorageAcct.Label).Primary"

When I built my context, I was not specifying the .label attribute of the storage account name. This caused the New-AzureStorageContext name to be given the wrong info. I needed to specify the .label on that command as well.

Here is what my context should have looked like.

$StorageAcct = Get-AzureStorageAccount -StorageAccountName $StorageAcctName
$StorageKey =(Get-AzureStorageKey -StorageAccountName $StorageAcct.Label).Primary
$StorageContext = New-AzureStorageContext -StorageAccountName $StorageAcct.Label -StorageAccountKey $StorageKey


  • Marked as answer by BMOT1 Monday, August 31, 2015 3:29 PM
  • Edited by BMOT1 Monday, August 31, 2015 3:29 PM
Free Windows Admin Tool Kit Click here and download it now
August 31st, 2015 3:29pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics