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 PowerBuilder Downloads
integer li_rc
long li_Success
oleobject loo_SavedUrl
string ls_Url
oleobject loo_Http
oleobject loo_Response
li_Success = 0
// Use a privately supplied COMPLETE HTTPS blob URL with a current SAS query.
// No account key is needed by this consumer.
li_Success = 0
loo_SavedUrl = create oleobject
li_rc = loo_SavedUrl.ConnectToNewObject("Chilkat.StringBuilder")
if li_rc < 0 then
destroy loo_SavedUrl
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_SavedUrl.LoadFile("qa_data/azure/blob-url.txt","utf-8")
if li_Success <> 1 then
Write-Debug "Could not load private SAS URL."
destroy loo_SavedUrl
return
end if
li_Success = loo_SavedUrl.Trim()
if li_Success <> 1 then
Write-Debug "Could not prepare the request."
destroy loo_SavedUrl
return
end if
if loo_SavedUrl.StartsWith("https://",0) <> 1 then
Write-Debug "An HTTPS SAS URL is required."
destroy loo_SavedUrl
return
end if
ls_Url = loo_SavedUrl.GetAsString()
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
loo_Http.RequireSslCertVerify = 1
loo_Http.FollowRedirects = 0
loo_Http.ConnectTimeout = 20
loo_Http.ReadTimeout = 60
loo_Http.SetRequestHeader("x-ms-version","2026-04-06")
loo_Http.SetRequestHeader("x-ms-blob-type","BlockBlob")
loo_Http.SetRequestHeader("If-None-Match","*")
loo_Response = create oleobject
li_rc = loo_Response.ConnectToNewObject("Chilkat.HttpResponse")
li_Success = loo_Http.HttpFile("PUT",ls_Url,"qa_data/bin/sample.bin","application/octet-stream",loo_Response)
if li_Success <> 1 then
Write-Debug "Upload did not complete; inspect diagnostics privately."
destroy loo_SavedUrl
destroy loo_Http
destroy loo_Response
return
end if
if loo_Response.StatusCode <> 201 then
Write-Debug "Upload rejected; inspect HTTP status and Azure error code privately."
destroy loo_SavedUrl
destroy loo_Http
destroy loo_Response
return
end if
Write-Debug "Blob created using the supplied SAS URL."
destroy loo_SavedUrl
destroy loo_Http
destroy loo_Response