Azure Blob: Upload a File Using a Complete SAS URL
See more Azure Cloud Storage Examples
Use a complete privately supplied HTTPS URL containing a valid SAS for the exact blob. This works with an appropriate service, account, or user delegation SAS; the consumer does not need the account key. The earlier embedded, expired token is removed. The required permission is create/write; If-None-Match prevents replacing an existing blob.
Keep the URL private and do not alter or double-encode the signature query. Redirects are disabled. This example uses Chilkat.Http directly for the full-URL convenience method; the other transfer examples show Chilkat.Rest.
Uses direct Chilkat REST calls with HTTPS certificate verification. Shared Key examples load a private qa_data/azure/storage.json file containing string fields account and access_key (the base64 account key). SAS consumers need only account there. Create local input/output directories before running. Examples target Azure public-cloud endpoints; adapt hostnames for other clouds or custom endpoints.
REST examples pin x-ms-version: 2026-04-06, and SAS generation uses the same service version. Complete-URL downloads use the supplied SAS version. This is a fully deployed version documented by Microsoft at review time. Older supported versions are not automatically obsolete. Transport completion and HTTP success are checked separately; writes are not automatically replayed after a lost response. Keep diagnostic dumps, keys and SAS URLs private.
Shared Key remains supported where allowed by account policy. Microsoft recommends Microsoft Entra ID, preferably managed identities where available, and user delegation SAS for delegated Blob access. Account-key SAS and Shared Key requests can be rejected when Shared Key access is disabled; these samples do not bypass that policy. See Azure data authorization.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoSavedUrl
String sUrl
Handle hoHttp
Variant vResponse
Handle hoResponse
Integer iTemp1
Boolean bTemp1
Move False To iSuccess
// Use a privately supplied COMPLETE HTTPS blob URL with a current SAS query.
// No account key is needed by this consumer.
Move False To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSavedUrl
If (Not(IsComObjectCreated(hoSavedUrl))) Begin
Send CreateComObject of hoSavedUrl
End
Get ComLoadFile Of hoSavedUrl "qa_data/azure/blob-url.txt" "utf-8" To iSuccess
If (iSuccess <> True) Begin
Showln "Could not load private SAS URL."
Procedure_Return
End
Get ComTrim Of hoSavedUrl To iSuccess
If (iSuccess <> True) Begin
Showln "Could not prepare the request."
Procedure_Return
End
Get ComStartsWith Of hoSavedUrl "https://" False To bTemp1
If (bTemp1 <> True) Begin
Showln "An HTTPS SAS URL is required."
Procedure_Return
End
Get ComGetAsString Of hoSavedUrl To sUrl
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Set ComRequireSslCertVerify Of hoHttp To True
Set ComFollowRedirects Of hoHttp To False
Set ComConnectTimeout Of hoHttp To 20
Set ComReadTimeout Of hoHttp To 60
Send ComSetRequestHeader To hoHttp "x-ms-version" "2026-04-06"
Send ComSetRequestHeader To hoHttp "x-ms-blob-type" "BlockBlob"
Send ComSetRequestHeader To hoHttp "If-None-Match" "*"
Get Create (RefClass(cComChilkatHttpResponse)) To hoResponse
If (Not(IsComObjectCreated(hoResponse))) Begin
Send CreateComObject of hoResponse
End
Get pvComObject of hoResponse to vResponse
Get ComHttpFile Of hoHttp "PUT" sUrl "qa_data/bin/sample.bin" "application/octet-stream" vResponse To iSuccess
If (iSuccess <> True) Begin
Showln "Upload did not complete; inspect diagnostics privately."
Procedure_Return
End
Get ComStatusCode Of hoResponse To iTemp1
If (iTemp1 <> 201) Begin
Showln "Upload rejected; inspect HTTP status and Azure error code privately."
Procedure_Return
End
Showln "Blob created using the supplied SAS URL."
End_Procedure