locked
What is this Context thing? RRS feed

  • Question

  • I'm trying to understand what these command want in the case of Context.

    Get-AzStorageContainer
    Get-AzStorageContainer : Could not get the storage context.  Please pass in a storage context or set the current storage context.

    I keep trying to figure out what the heck the command wants.  What in the context does this command want?


    David Jenkins

    Thursday, September 26, 2019 9:19 PM

Answers

  • Hey David,

    The Context gets metadata of your storage account, to get the context of your account use the following:

    $Context = New-AzStorageContext $StorageAccountName -StorageAccountKey "yourkey"

    then in your command use the following: 

    Get-AzStorageContainer -Context $Context

    This should resolve the issue, let me know if this helps.

    Thursday, September 26, 2019 10:17 PM

All replies

  • Hey David,

    The Context gets metadata of your storage account, to get the context of your account use the following:

    $Context = New-AzStorageContext $StorageAccountName -StorageAccountKey "yourkey"

    then in your command use the following: 

    Get-AzStorageContainer -Context $Context

    This should resolve the issue, let me know if this helps.

    Thursday, September 26, 2019 10:17 PM
  • Thank you for your help. 

    When using $Context = New-AzStorageContext $StorageAccountName -StorageAccountKey "yourkey" am I creating something or just "getting" context?

    I also wonder what Get-AzContext does then.  I was trying to use that to get my current context and use that but it fails.


    David Jenkins


    Friday, September 27, 2019 7:51 PM
  • Thank you. 

    David Jenkins

    Friday, September 27, 2019 8:04 PM
  • Hi David, 

    so the $Context is the variable containing metadata of the storage account, which includes the Endpoints of different services for blob storage, File storage , location etc.... When you generate it via the previous command, and type $Context in powershell, it will give you  the response of that metada(Endpoints)

    The "youkey" portion would be the Access Key(Located in the Azure Portal Panel). 

    Thanks,

    Adam

    Friday, September 27, 2019 9:21 PM