Azure Table: Create a Read-Only Table Service SAS
See more Azure Table Service Examples
Generates a short-lived HTTPS-only account-key service SAS for ExampleCustomers, restricted to one partition and the inclusive lexical row range customer-001 through customer-099. Includes Table-specific spk/srk/epk/erk fields, lowercase canonical table name and tn. It grants entity reads, not table creation/deletion or policy administration. Respect stricter account SAS-expiration policies.
Writes a token without a leading question mark to private table-sas.txt, replacing a prior token. Anyone holding it can exercise its permissions until expiry; do not log it. This is an account-key Table service SAS, not a Blob user-delegation SAS.
Targets Azure Storage Table service in the public cloud, not Azure Cosmos DB for Table. Uses Chilkat 11.6.0 or later and an unlocked library. Direct data requests pin x-ms-version 2026-04-06 and OData 3.0. Shared Key examples read private qa_data/azure/storage.json with account and access_key string fields. Authentication examples explain their additional fields. Create private local directories before running; keep credentials, tokens, SAS, entity values, checkpoints and diagnostics outside public content and source control.
HTTPS certificates are verified. Transport completion and HTTP status are checked separately. Writes are not automatically retried after an uncertain outcome. Entity keys, ETags and continuation tokens remain strings. Examples operate on the existing ExampleCustomers table unless noted; review the targets before adapting them. Microsoft Entra ID with suitable Table data roles is preferred where available.
Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' StringBuilder compares text by value in every generated language.
set textCompare = Server.CreateObject("Chilkat.StringBuilder")
' Assumes Chilkat is unlocked. See Global Unlock Sample.
success = 0
set config = Server.CreateObject("Chilkat.JsonObject")
config.Strict = 1
success = config.LoadFile("qa_data/azure/storage.json")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not load private Azure configuration.") & "</pre>"
Response.End
End If
textCompare.Clear
success = textCompare.SetString(config.StringOf("account"))
sameText1 = textCompare.ContentsEqual("",1)
If ((config.JsonTypeOf("account") <> 1) Or (sameText1 = 1)) Then
Response.Write "<pre>" & Server.HTMLEncode( "Supply the storage account name.") & "</pre>"
Response.End
End If
' access_key is the base64 account key, not a connection string or SAS.
textCompare.Clear
success = textCompare.SetString(config.StringOf("access_key"))
sameText2 = textCompare.ContentsEqual("",1)
If ((config.JsonTypeOf("access_key") <> 1) Or (sameText2 = 1)) Then
Response.Write "<pre>" & Server.HTMLEncode( "Supply the base64 account access key.") & "</pre>"
Response.End
End If
set sas = Server.CreateObject("Chilkat.AuthAzureSAS")
sas.AccessKey = config.StringOf("access_key")
sas.StringToSign = "sp,st,se,resource,si,sip,spr,sv,spk,srk,epk,erk"
set canonical = Server.CreateObject("Chilkat.StringBuilder")
success = canonical.Append("/table/")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = canonical.Append(config.StringOf("account"))
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = canonical.Append("/examplecustomers")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetNonTokenParam("resource",canonical.GetAsString())
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
' Canonicalized table name must be lowercase. tn belongs in the token, not StringToSign.
set start = Server.CreateObject("Chilkat.CkDateTime")
set expiry = Server.CreateObject("Chilkat.CkDateTime")
success = start.SetFromCurrentSystemTime()
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = expiry.SetFromCurrentSystemTime()
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = start.AddSeconds(-300)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = expiry.AddSeconds(900)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("tn","tn","examplecustomers")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("sp","sp","r")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("st","st",start.GetAsTimestamp(0))
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("se","se",expiry.GetAsTimestamp(0))
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("spr","spr","https")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("sv","sv","2026-04-06")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("spk","spk","customers-west")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("epk","epk","customers-west")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("srk","srk","customer-001")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
success = sas.SetTokenParam("erk","erk","customer-099")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not prepare the request.") & "</pre>"
Response.End
End If
sasToken = sas.GenerateToken()
If (sas.LastMethodSuccess <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not sign the SAS.") & "</pre>"
Response.End
End If
set files = Server.CreateObject("Chilkat.FileAccess")
success = files.WriteEntireTextFile("qa_data/azure/table-sas.txt",sasToken,"utf-8",0)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Could not save private SAS token.") & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Read-only Table SAS saved privately; expires in about 15 minutes.") & "</pre>"
%>
</body>
</html>