How to use powershell to connect to Azure blob storage using SAS token?

willi@m 0 Reputation points
2023-07-25T07:03:59.32+00:00

How to use powershell to connect to Azure blob by given information as below

https://[accountName].blob.core.windows.net/[containerName]?sp=racwdlm&se=2025-01-01T10:56:10Z&&spr=https&sv=2023-07-24&sr=c&sig=31SszeTmRh4CVyrBDMeWQ22mD1L______k%2BMQKk4%3D

trying to figure using az storage blob list --accountname [accountName] --sas-token sp=racwdlm&se=2025-01-01T10:56:10Z&&spr=https&sv=2023-07-24&sr=c&sig=31SszeTmRh4CVyrBDMeWQ22mD1L______k%2BMQKk4%3D

However it failed

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,538 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. shiva patpi 12,961 Reputation points Microsoft Employee
    2023-07-25T16:34:02.07+00:00

    @willi@m I just tried below command and it went through successfully !!

    az storage blob list --account-name "straccountname" --container-name "books" -o table --sas-token "?sv=2022-11-02&ss=b&srt=sco&sp=rwdlaciytfx&se=2023-07-30T00:15:13Z&st=2023-07-24T16:15:13Z&spr=https&sig=saso%3D"

    Couple of things:

    1. While generating the SAS token try to give Start time like an hour before and select the appropriate end time
    2. Make sure to keep the SAS Token in double quotes
    3. Try to run in normal command prompt or also try in powershell prompt

    Here is the screen shot of successful execution of the command:

    User's image