locked
Powershell: Getting SAS key from Blob storage RRS feed

  • Question

  • Hi

    I am trying to generate a connection string to a Blob store and a Servicebus from powershell, the keys that i need to use, is generated, but i cannot get them from powershell.

    Can anyone tell me how to get the accesskeys?

    I can get my access policy with: Get-AzStorageContainerStoredAccessPolicy 

    But how do i get the key associated with this accesspolicy?

    Thanks on adwance

    /Graves

    Friday, January 25, 2019 10:47 AM

Answers

All replies

  • Hi

    I am trying to generate a connection string to a Blob store and a Servicebus from powershell, the keys that i need to use, is generated, but i cannot get them from powershell.

    Can anyone tell me how to get the accesskeys?

    I can get my access policy with: Get-AzStorageContainerStoredAccessPolicy 

    But how do i get the key associated with this accesspolicy?

    Thanks on adwance

    /Graves

    Have a look at get-azstorageaccountkey

    Link : https://docs.microsoft.com/en-us/powershell/module/az.Storage/Get-azStorageAccountKey?view=azps-1.1.0

    Friday, January 25, 2019 11:27 AM
  • Hi 

    Thanks, but It is not the key i need, the key should be asoiated with the:
    Get-AzStorageContainerStoredAccessPolicy, but I am only getting the policy id when i ask for it, i need the Access id also.

    the connection string is like shown here:AzureConnectionString

    I might be wrong, i am not that skilled in how to use the SAS tokens yet, but if it is not the sas key, what is it then?

    Thanks 

    /Graves

    Friday, January 25, 2019 11:57 AM
  • Hi Graves,

    Can you let us know how were the keys generated in the first place?

    To generate the SAS Token, you would need to use the below command

    New-AzStorageContainerSASToken -Name "Test" -Policy "PolicyName"

    https://docs.microsoft.com/en-us/powershell/module/az.storage/new-azstoragecontainersastoken?view=azps-1.1.0

    You can then store the generated SAS Token in a variable for further use. There is not "Get" command for the same.

    Hope this helps!

    Friday, January 25, 2019 1:47 PM
  • Hi 

    Oh that explains it..

    Thanks, I will modify my scripts to create a New SAS token :-)

    /Graves

    Monday, January 28, 2019 6:54 AM
  • Hi again

    thanks for the answer, it looks like i am getteing the right connection string..

    Can you tell me how i get the same type of connection string from a service bus?

    I need to get at connection string that looks like the one from the storragecontainer.

    Thank

    Tuesday, January 29, 2019 10:57 AM
  • Hi Graves

    Please use the below command to fetch the connection string for a service bus

    $resourceGroup = "myResourceGroup"
    $serviceBusName ="myservicebusname"
    $policyName = "policyname"
    
    Get-AzureRmServiceBusNamespaceKey -ResourceGroup $resourceGroup -Name $serviceBusName -AuthorizationRuleName $policyName

    Hope this helps!

    Tuesday, January 29, 2019 6:55 PM
  • Hi again 

    the command Get-AzureRmServiceBusNamespaceKey is not in the AzureRM module anymore, is there a command that have replaced it?

    /Graves

    Wednesday, January 30, 2019 12:11 PM
  • Yes it seems to be replaced by Get-AzureRmServiceBusKey.

    https://docs.microsoft.com/en-us/powershell/module/azurerm.servicebus/get-azurermservicebuskey?view=azurermps-6.13.0

    Please try using the below:

    Get-AzureRmServiceBusKey -ResourceGroup <ResourceGroupName> -Namespace <NamespaceName> -Name <AuthorizationRuleName>

    Hope this helps!


    Wednesday, January 30, 2019 5:32 PM
  • Thanks i will try to get the string with this command :-)

    Wednesday, February 6, 2019 7:05 AM