Azure Storage Accounts: Create an Account and Monitor Provisioning
See more Azure Storage Accounts Examples
Creates a general-purpose v2 account using direct Chilkat.Http calls and API version 2026-09-01, then monitors provisioning. This operation can create billable resources and can update an existing account at the same resource ID. Review the target and body before running it.
Set the subscription, an existing resource group, a globally unique account name (3-24 lowercase letters or digits), and a supported region. Register Microsoft.Storage for the subscription if necessary. The caller needs account write/read permissions and permission to monitor the operation at resource-group scope. Azure policy, quota, resource locks, and SKU availability can also affect the request.
The sample selects StorageV2, Standard_LRS, and the Hot tier. It requires HTTPS, sets the account's minimum TLS version to 1.2, and disables anonymous blob access. This does not configure private networking or disable Shared Key authentication; choose those policies separately for the intended clients. The minimum-TLS property controls storage clients, not the TLS protocol negotiated by Chilkat.Http.
HTTP 202 means accepted, not ready. The code prefers Azure-AsyncOperation when present, otherwise uses Location, honors integer Retry-After delays, and verifies the final resource state. Polling is bounded. Long or non-integer delays pause the sample for later resumption. Save the printed URL, monitor type, and retry interval; set operationUrl and operationUsesStatus to resume without another PUT. In production, persist this state and schedule polling without blocking the UI.
A timeout after submitting the PUT does not prove that Azure rejected it. Inspect the target resource before submitting again. On polling failures or time limits, resume monitoring instead of creating another request. See tracking asynchronous Azure operations.
These calls manage Azure resources at management.azure.com. They do not upload or download stored data. Supply a current Microsoft Entra access token for Azure Resource Manager in private qa_data/tokens/azureToken.json, with a nonempty access_token string. For v2 client credentials, request https://management.azure.com/.default; obtain a new token when it expires. A storage account key, SAS, Microsoft Graph token, or Storage data-plane token is not an ARM token. Never print the token or commit its file.
Azure RBAC must grant the caller the required management actions at the appropriate scope. An app registration alone does not grant resource access. Management permissions and blob/file data permissions are distinct. These examples target public Azure; sovereign clouds require the corresponding authority, ARM endpoint, token audience, and continuation-host validation.
Chilkat VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
set stringCompare = CreateObject("Chilkat.StringBuilder")
' This example requires the Chilkat API to have been previously unlocked.
' See Global.UnlockBundle for sample code.
' This is Azure Resource Manager (the management plane), not a blob data request.
' Load an unexpired Microsoft Entra token whose audience is Azure Resource Manager.
' For the v2 token endpoint, request scope https://management.azure.com/.default.
' Keep the token file private and out of source control and public web directories.
set token = CreateObject("Chilkat.JsonObject")
token.Strict = 1
success = token.LoadFile("qa_data/tokens/azureToken.json")
If (success <> 1) Then
outFile.WriteLine("Could not load the private Azure Resource Manager token file.")
WScript.Quit
End If
If ((token.JsonTypeOf("access_token") <> 1) Or (token.StringOfEquals("access_token","",1) = 1)) Then
outFile.WriteLine("A nonempty access_token string is required.")
WScript.Quit
End If
' Use your subscription ID as a string. The all-zero value is only a placeholder.
subscriptionId = "00000000-0000-0000-0000-000000000000"
set http = CreateObject("Chilkat.Http")
http.AuthToken = token.StringOf("access_token")
http.Accept = "application/json"
http.RequireSslCertVerify = 1
http.FollowRedirects = 0
http.ConnectTimeout = 30
http.ReadTimeout = 60
success = http.SetUrlVar("subscriptionId",subscriptionId)
If (success <> 1) Then
outFile.WriteLine("Could not encode subscription ID.")
WScript.Quit
End If
set response = CreateObject("Chilkat.HttpResponse")
set result = CreateObject("Chilkat.JsonObject")
result.Strict = 1
set parsed = CreateObject("Chilkat.Url")
' Choose an EXISTING resource group and a globally unique 3-24 character name
' containing only lowercase letters and digits. Choose a supported Azure region.
resourceGroupName = "my-resource-group"
accountName = "youruniquestorageaccount"
location = "eastus"
success = http.SetUrlVar("resourceGroupName",resourceGroupName)
If (success <> 1) Then
outFile.WriteLine("Could not encode resource group.")
WScript.Quit
End If
success = http.SetUrlVar("accountName",accountName)
If (success <> 1) Then
outFile.WriteLine("Could not encode account name.")
WScript.Quit
End If
resourceUrl = "https://management.azure.com/subscriptions/{$subscriptionId}/resourceGroups/{$resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{$accountName}?api-version=2026-09-01"
' To resume monitoring, paste the operation URL printed by an earlier run here.
' Also set operationUsesStatus to the printed value (Azure-AsyncOperation=true,
' Location=false). A nonempty operationUrl skips the PUT completely.
operationUrl = ""
operationUsesStatus = 0
' When resuming, first wait for the Retry-After interval from the prior response.
retryAfter = ""
success = stringCompare.SetString(operationUrl)
stringMatch1 = stringCompare.ContentsEqual("",1)
If (stringMatch1 = 1) Then
set request = CreateObject("Chilkat.JsonObject")
success = request.UpdateString("location",location)
success = request.UpdateString("kind","StorageV2")
success = request.UpdateString("sku.name","Standard_LRS")
success = request.UpdateString("properties.accessTier","Hot")
success = request.UpdateBool("properties.supportsHttpsTrafficOnly",1)
success = request.UpdateString("properties.minimumTlsVersion","TLS1_2")
success = request.UpdateBool("properties.allowBlobPublicAccess",0)
' This PUT can UPDATE an existing account at this resource ID.
' Review the target and settings first. Creating storage can incur charges.
success = http.HttpJson("PUT",resourceUrl,request,"application/json",response)
' If transport fails, inspect this resource before deciding to submit again;
' Azure may already have accepted the PUT.
If (response.StatusCode = 0) Then
outFile.WriteLine("No HTTP response. Inspect LastErrorText privately; it may contain credentials.")
WScript.Quit
End If
If ((response.StatusCode <> 200) And (response.StatusCode <> 202)) Then
outFile.WriteLine("HTTP status: " & response.StatusCode)
outFile.WriteLine("Request ID: " & response.GetHeaderField("x-ms-request-id"))
outFile.WriteLine("Retry-After: " & response.GetHeaderField("Retry-After"))
' Inspect the error body privately. Do not log tokens, headers, or full responses.
' For 401 check the token/audience; for 403 check Azure RBAC and policy.
' Honor Retry-After for 429 and use bounded backoff for transient failures.
WScript.Quit
End If
If (success <> 1) Then
outFile.WriteLine("The HTTP response could not be read completely.")
WScript.Quit
End If
If (response.StatusCode = 202) Then
' An accepted operation can have an EMPTY body. Do not try to parse it.
operationUrl = response.GetHeaderField("Azure-AsyncOperation")
success = stringCompare.SetString(operationUrl)
stringMatch2 = stringCompare.ContentsEqual("",1)
If (stringMatch2 <> 1) Then
operationUsesStatus = 1
Else
operationUrl = response.GetHeaderField("Location")
End If
success = stringCompare.SetString(operationUrl)
stringMatch3 = stringCompare.ContentsEqual("",1)
If (stringMatch3 = 1) Then
outFile.WriteLine("Accepted, but no monitor URL was returned. Check the resource; do not assume success.")
WScript.Quit
End If
retryAfter = response.GetHeaderField("Retry-After")
End If
End If
success = stringCompare.SetString(operationUrl)
stringMatch4 = stringCompare.ContentsEqual("",1)
If (stringMatch4 <> 1) Then
success = parsed.ParseUrl(operationUrl)
If (success <> 1) Then
outFile.WriteLine("Missing or invalid continuation URL.")
WScript.Quit
End If
success = stringCompare.SetString(parsed.Scheme)
stringMatch5 = stringCompare.ContentsEqual("https",1)
success = stringCompare.SetString(parsed.Host)
stringMatch6 = stringCompare.ContentsEqual("management.azure.com",1)
success = stringCompare.SetString(parsed.Login)
stringMatch7 = stringCompare.ContentsEqual("",1)
success = stringCompare.SetString(parsed.Password)
stringMatch8 = stringCompare.ContentsEqual("",1)
success = stringCompare.SetString(parsed.Frag)
stringMatch9 = stringCompare.ContentsEqual("",1)
If ((stringMatch5 <> 1) Or (stringMatch6 <> 1) Or (parsed.Port <> 443) Or (stringMatch7 <> 1) Or (stringMatch8 <> 1) Or (stringMatch9 <> 1)) Then
outFile.WriteLine("Unexpected continuation URL; refusing to send the access token.")
WScript.Quit
End If
outFile.WriteLine("Operation URL (save for resuming): " & operationUrl)
outFile.WriteLine("operationUsesStatus: " & operationUsesStatus)
set retryText = CreateObject("Chilkat.StringBuilder")
set retryNumber = CreateObject("Chilkat.StringBuilder")
attempt = 0
complete = 0
Do While ((attempt < 30) And (complete <> 1))
' Bound the example's polling. A desktop UI should schedule this work in
' the background. A production worker should persist the URL and next poll time.
waitSeconds = 5
success = stringCompare.SetString(retryAfter)
stringMatch10 = stringCompare.ContentsEqual("",1)
If (stringMatch10 <> 1) Then
success = retryText.SetString(retryAfter)
success = retryText.Trim()
waitSeconds = retryText.IntValue
retryNumber.Clear
success = retryNumber.AppendInt(waitSeconds)
If ((retryText.ContentsEqual(retryNumber.GetAsString(),1) <> 1) Or (waitSeconds < 0) Or (waitSeconds > 60)) Then
' Do not shorten a long server-requested delay. Save the operation
' URL above and resume later; an HTTP-date needs a scheduler too.
outFile.WriteLine("Polling paused. Resume after Retry-After: " & retryAfter)
WScript.Quit
End If
End If
If (waitSeconds = 0) Then
waitSeconds = 1
End If
http.SleepMs waitSeconds * 1000
success = http.HttpNoBody("GET",operationUrl,response)
If (response.StatusCode = 0) Then
outFile.WriteLine("No HTTP response. Inspect LastErrorText privately; it may contain credentials.")
WScript.Quit
End If
If ((response.StatusCode <> 200) And (response.StatusCode <> 202) And (response.StatusCode <> 204)) Then
outFile.WriteLine("HTTP status: " & response.StatusCode)
outFile.WriteLine("Request ID: " & response.GetHeaderField("x-ms-request-id"))
outFile.WriteLine("Retry-After: " & response.GetHeaderField("Retry-After"))
' Inspect the error body privately. Do not log tokens, headers, or full responses.
' For 401 check the token/audience; for 403 check Azure RBAC and policy.
' Honor Retry-After for 429 and use bounded backoff for transient failures.
WScript.Quit
End If
If (success <> 1) Then
outFile.WriteLine("The HTTP response could not be read completely.")
WScript.Quit
End If
attempt = attempt + 1
retryAfter = response.GetHeaderField("Retry-After")
If (operationUsesStatus = 1) Then
success = result.Load(response.BodyStr)
If (success <> 1) Then
outFile.WriteLine("Expected a well-formed JSON response.")
WScript.Quit
End If
If ((result.JsonTypeOf("status") <> 1) Or (result.StringOfEquals("status","",1) = 1)) Then
outFile.WriteLine("Expected a nonempty operation status.")
WScript.Quit
End If
If ((result.StringOfEquals("status","Failed",1) = 1) Or (result.StringOfEquals("status","Canceled",1) = 1)) Then
outFile.WriteLine("Provisioning did not succeed: " & result.StringOf("status"))
outFile.WriteLine("Error code: " & result.StringOf("error.code"))
WScript.Quit
End If
complete = result.StringOfEquals("status","Succeeded",1)
Else
' Location: 202 is still pending; 200/204 completes the monitor request.
' Get the resource below to confirm its provisioningState.
complete = response.StatusCode <> 202
End If
Loop
If (complete <> 1) Then
outFile.WriteLine("Polling limit reached; provisioning may still be running.")
outFile.WriteLine("Resume using the saved operation URL. Retry-After: " & retryAfter)
WScript.Quit
End If
End If
' Read the final resource for both immediate and asynchronous completion.
success = http.HttpNoBody("GET",resourceUrl,response)
If (response.StatusCode = 0) Then
outFile.WriteLine("No HTTP response. Inspect LastErrorText privately; it may contain credentials.")
WScript.Quit
End If
If ((response.StatusCode <> 200)) Then
outFile.WriteLine("HTTP status: " & response.StatusCode)
outFile.WriteLine("Request ID: " & response.GetHeaderField("x-ms-request-id"))
outFile.WriteLine("Retry-After: " & response.GetHeaderField("Retry-After"))
' Inspect the error body privately. Do not log tokens, headers, or full responses.
' For 401 check the token/audience; for 403 check Azure RBAC and policy.
' Honor Retry-After for 429 and use bounded backoff for transient failures.
WScript.Quit
End If
If (success <> 1) Then
outFile.WriteLine("The HTTP response could not be read completely.")
WScript.Quit
End If
success = result.Load(response.BodyStr)
If (success <> 1) Then
outFile.WriteLine("Expected a well-formed JSON response.")
WScript.Quit
End If
If (result.StringOfEquals("properties.provisioningState","Succeeded",1) <> 1) Then
outFile.WriteLine("Account is not confirmed ready. Provisioning state: " & result.StringOf("properties.provisioningState"))
' If pending, GET this resource later; do not repeat PUT just to check status.
WScript.Quit
End If
If ((result.JsonTypeOf("id") <> 1) Or (result.StringOfEquals("id","",1) = 1)) Then
outFile.WriteLine("Expected the provisioned account's resource ID.")
WScript.Quit
End If
outFile.WriteLine("Storage account provisioning succeeded.")
outFile.WriteLine("Resource ID: " & result.StringOf("id"))
outFile.WriteLine("Name: " & result.StringOf("name"))
outFile.WriteLine("Blob endpoint: " & result.StringOf("properties.primaryEndpoints.blob"))
' Provisioning success does not grant blob/file data access. Configure data-plane
' roles and the account's network policy separately for the application that uses it.
outFile.Close