Generating a Shared Access Signature (SAS) token for your Azure Storage is important for managing secure access to different storage resources. In this article, I will walk you through all the approaches to doing this.
Table of Contents
How To Generate SAS Token For Azure Storage
A SAS token for Azure storage can help you secure access to a resource inside your Azure storage account. Let’s discuss each method individually.
Approach-1: Using Azure Portal
To Generate SAS Token For Azure Storage, Follow the below steps.
1. Log in to the Azure Portal.
2. Search for Storage accounts and then click on the search result Storage accounts as shown in the screenshot below.

3. Click on the specific storage from the lists for the one you wish to generate the SAS access token.

4. Expand the Security + networking tab, then click on the Shared access signature link as shown in the screenshot below.

5. Select the required options for Allowed permissions, set the start and expiration date, etc., based on your requirements, and finally, click on the Generate SAS and connection string button, as highlighted in the screenshot below.


Now, the SAS token is generated successfully below the button, as shown in the screenshot below.

Check out: Create a storage account in Azure
Approach-2: Using PowerShell
We can execute the below PowerShell script to generate the SAS access token for the alazureml7822510715 storage account.
$strgact_name = "alazureml7822510715"
$strgact_key = "ogCGYSTLBnJkYtO5O9lPdB5K4uRjEKF9a8x+21JouWOYeiDi/mBq4eq7M7CAsyCv0r6RvqoB5sq3+ASttMeBSg=="
$mycontext = New-AzStorageContext -StorageAccountName $strgact_name -StorageAccountKey $strgact_key
#you can also add other parameters like ExpiryTime etc based on your requirement.
New-AzStorageAccountSASToken -Service Blob -ResourceType Service,Container,Object -Permission rl -Context $mycontextThe query executed successfully and the SAS token also got generated successfully as shown in the screenshot below.

Check out: Move storage account to another region
Approach-3: Using Azure CLI
We can also execute the Azure CLI script below to generate the SAS Token.
az storage container generate-sas --account-name alazureml7822510715 --name azureml --permissions acdlrw --expiry 2024-11-15 --auth-mode login --as-userAfter executing the above query, I got the SAS token successfully as highlighted in the screenshot below.

Video Tutorial
Conclusion
Generating a Shared Access Signature (SAS) token is a great way of securing your Azure resource inside your Azure storage account. As explained in this article, you can get a SAS token for your Azure storage account using Azure Portal, PowerShell, or Azure CLI.
You may also like following the articles below.
- How To Create Azure Data Lake Storage Gen2
- How to Upload and Download File From Azure Blob Storage Using C# and PowerShell
- How To Create Blob Storage In Azure

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
