A SAS (Shared Access Signature) URL provides secure delegated access to resources in an Azure Storage account. The SAS URL you’ve shared grants specific permissions (like read, write, or delete) over a defined period. Here’s a guide on how to use it:
Key Components of the SAS URL:
- Base URL:
https://bmtdwhuksstrdev.blob.core.windows.net/hubspot
This is the Azure Storage account and the container you’re accessing (hubspot
). - SAS Token (query parameters):
sp=racwl
: Defines the permissions you have (in this case, Read, Add, Create, Write, and List).st=2024-04-29T10:23:02Z
: Start time (UTC) when the token becomes valid.se=2024-10-22T18:23:02Z
: Expiry time (UTC) when the token becomes invalid.spr=https
: Specifies that HTTPS is required for secure access.sv=2022-11-02
: Indicates the Azure Storage Service version.sr=c
: The resource being accessed is a container (c
).sig=lAqJZk%2BoUHFZYhXlI####1Dg17hpgAhM%3D
: The cryptographic signature that authorises access.
Security Reminder
Keep your SAS URL secure! Avoid sharing it with unauthorised individuals, as anyone with the link can perform the permitted actions.
Using the SAS URL for Different Operations
You can perform several actions based on the permissions provided in the SAS token. Here are some common tasks:
Using a SAS (Shared Access Signature) URL to attach Azure Container
Downloading Files:
If you want to download files, you can use the SAS URL directly in a browser or with tools like curl
or Azure CLI.
Example using curl
:
curl -O "https://bmtdwhuksstrdev.blob.core.windows.net/hubspot/filename?sp=racwl&st=2024-04-29T10:23:02Z&se=2024-10-22T18:23:02Z&spr=https&sv=2022-11-02&sr=c&sig=lAqJZk%2BoUHFZYhXlI####1Dg17hpgAhM%3D"
Uploading Files:
Since you have write permission, you can upload files to the container.
Example using Azure CLI:
az storage blob upload --container-name hubspot --name "filename" --file "localfile" --account-name bmtdwhuksstrdev --sas-token ""
Listing Files in the Container:
You can list all the blobs (files) in the container using the following Azure CLI command:
az storage blob list --container-name hubspot --account-name bmtdwhuksstrdev --sas-token "<SAS_TOKEN>"
Programmatic Access:
You can interact with the storage programmatically using libraries like azure-storage-blob
.
Example in Python:
from azure.storage.blob import BlobServiceClient
sas_url = "https://bmtdwhuksstrdev.blob.core.windows.net/hubspot?sp=racwl&st=2024-04-29T10:23:02Z&se=2024-10-22T18:23:02Z&spr=https&sv=2022-11-02&sr=c&sig=lAqJZk%2BoUHFZYhXlI####1Dg17hpgAhM%3D"
blob_service_client = BlobServiceClient(account_url=sas_url)
container_client = blob_service_client.get_container_client("hubspot")
blobs_list = container_client.list_blobs()
for blob in blobs_list:
print(blob.name)
1 thought on “Understanding the SAS URL”