Sample code for 30+ languages & platforms
AutoIt Requires Chilkat v11.6.0+

Azure Blob: Create a Private Container

See more Azure Cloud Storage Examples

Create a private container by omitting x-ms-blob-public-access. Container names must meet Azure naming rules. HTTP 409 is not automatically success: inspect the error code, because ContainerAlreadyExists and ContainerBeingDeleted have different meanings.

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.

Microsoft create container reference.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  StringBuilder compares text by value in every generated language.
$oTextCompare = ObjCreate("Chilkat.StringBuilder")
;  Assumes Chilkat is unlocked. See Global Unlock Sample.
$bSuccess = False
$oConfig = ObjCreate("Chilkat.JsonObject")
$oConfig.Strict = True
$bSuccess = $oConfig.LoadFile("qa_data/azure/storage.json")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not load private Azure configuration." & @CRLF)
    Exit
EndIf

$oTextCompare.Clear 
$oTextCompare.SetString($oConfig.StringOf("account"))
Local $bSameText1 = $oTextCompare.ContentsEqual("",True)
If (($oConfig.JsonTypeOf("account") <> 1) Or ($bSameText1 = True)) Then
    ConsoleWrite("Supply the storage account name." & @CRLF)
    Exit
EndIf

;  access_key is the base64 account key, not a connection string or SAS.
$oTextCompare.Clear 
$oTextCompare.SetString($oConfig.StringOf("access_key"))
Local $bSameText2 = $oTextCompare.ContentsEqual("",True)
If (($oConfig.JsonTypeOf("access_key") <> 1) Or ($bSameText2 = True)) Then
    ConsoleWrite("Supply the base64 account access key." & @CRLF)
    Exit
EndIf

$oEndpoint = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oEndpoint.Append($oConfig.StringOf("account"))
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oEndpoint.Append(".blob.core.windows.net")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

;  resourcePath is already URL-encoded. Encode each path segment once when adapting it.
;  Keep slash separators; names and paths are case-sensitive.
Local $sResourcePath = "/examplecontainer"
$oRest = ObjCreate("Chilkat.Rest")
$oRest.ConnectTimeoutMs = 20000
$oRest.IdleTimeoutMs = 60000
$oAzAuth = ObjCreate("Chilkat.AuthAzureStorage")
$oAzAuth.Account = $oConfig.StringOf("account")
$oAzAuth.AccessKey = $oConfig.StringOf("access_key")
$oAzAuth.Service = "Blob"
$oAzAuth.Scheme = "SharedKey"
$oAzAuth.XMsVersion = "2026-04-06"
$bSuccess = $oRest.SetAuthAzureStorage($oAzAuth)
If ($bSuccess <> True) Then
    ConsoleWrite("Could not configure Shared Key signing." & @CRLF)
    Exit
EndIf

$oConnection = ObjCreate("Chilkat.Socket")
$oConnection.RequireSslCertVerify = True
$oConnection.MaxReadIdleMs = 60000
$oConnection.MaxSendIdleMs = 60000
$bSuccess = $oConnection.Connect($oEndpoint.GetAsString(),443,True,20000)
If ($bSuccess <> True) Then
    ConsoleWrite("TLS connection failed; inspect diagnostics privately." & @CRLF)
    Exit
EndIf

;  Do not replay a write automatically after losing its response.
$bSuccess = $oRest.UseConnection($oConnection,False)
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

Local $sResponseText
$oResult = ObjCreate("Chilkat.Xml")
$oResult.Strict = True
$bSuccess = $oRest.AddQueryParam("restype","container")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$sResponseText = $oRest.FullRequestNoBody("PUT",$sResourcePath)
If ($oRest.LastMethodSuccess <> True) Then
    ConsoleWrite("Request did not complete; outcome may be uncertain." & @CRLF)
    Exit
EndIf

If ($oRest.ResponseStatusCode <> 201) Then
    ConsoleWrite("HTTP status: " & $oRest.ResponseStatusCode & @CRLF)
    ConsoleWrite("Azure error code: " & $oRest.ResponseHdrByName("x-ms-error-code") & @CRLF)
    ConsoleWrite("Request ID: " & $oRest.ResponseHdrByName("x-ms-request-id") & @CRLF)
    ;  Inspect any error body privately; do not log credentials, SAS URLs or payloads.
    Exit
EndIf

ConsoleWrite("Container operation completed." & @CRLF)