0

I am working on Powershell script that could extract Azure Storage Container details which includes SAS Token, Connection String, Expiry dates and File Service SAS URL. But I don't see any command to extract those details other than the SAS Token creation.

Could you please suggest the ways to extract those details through powershell or Azure Cli?

enter image description here

6
  • Could you please confirm if you want to retrive the sas token creation date ,Other then that you are getting all the details. Commented Apr 20, 2022 at 3:51
  • Could you please provide the command that you have tried so far Commented Apr 20, 2022 at 4:14
  • Have you checked the Az modules for related commands? Az storage docs Commented Apr 20, 2022 at 4:20
  • For SAS token creation I used below command New-AzStorageAccountSASToken -Service File -ResourceType Container -Permission "rwdl" -ExpiryTime (Get-Date).AddDays(7) -Context $StorageContext Commented Apr 20, 2022 at 20:33
  • @Todd, Yes I gone through the Az storage docs link. I have found the command to create SAS Token but not for the Connection String and File Service SAS URL. As reffered in the screen shot I would like have All 3 ( SAS Token, Connection String and File Service SAS URL) through Power Shell Commands. I could get the SAS Token with New-AzStorageAccountSASToken, Now I need other 2. So looking for the Power Shell command to get those. Commented Apr 20, 2022 at 23:17

1 Answer 1

0

AFAIK,Using New-AzStorageAccountSASToken while we generate storage account sas token, will get the output of sas token only not connection string and blob service uri etc.

This provide the following parameter:

New-AzureStorageAccountSASToken
   -Service <SharedAccessAccountServices>
   -ResourceType <SharedAccessAccountResourceTypes>
   [-Permission <String>]
   [-Protocol <SharedAccessProtocol>]
   [-IPAddressOrRange <String>]
   [-StartTime <DateTime>]
   [-ExpiryTime <DateTime>]
   [-Context <IStorageContext>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

As shown below:

enter image description here

To extract the connection string of our storage account we can use the below cmd :

az storage account show-connection-string --name MySA --resource-group MyRG --subscription MySubscription

enter image description here

To extract the blob service url we can use the below cmd :

 az storage blob generate-sas -c containername -n myfile.json --permissions r --expiry 2018-01-01T00:00:00Z --full-uri

enter image description here

For more information please refer the below links:-

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.