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

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.

Microsoft API reference

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

set stringCompare = Server.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 = Server.CreateObject("Chilkat.JsonObject")
token.Strict = 1
success = token.LoadFile("qa_data/tokens/azureToken.json")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Could not load the private Azure Resource Manager token file.") & "</pre>"
    Response.End
End If

If ((token.JsonTypeOf("access_token") <> 1) Or (token.StringOfEquals("access_token","",1) = 1)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "A nonempty access_token string is required.") & "</pre>"
    Response.End
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 = Server.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
    Response.Write "<pre>" & Server.HTMLEncode( "Could not encode subscription ID.") & "</pre>"
    Response.End
End If

ERROR: ASP example cannot use request or response as a variable name.
set result = Server.CreateObject("Chilkat.JsonObject")
result.Strict = 1
set parsed = Server.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
    Response.Write "<pre>" & Server.HTMLEncode( "Could not encode resource group.") & "</pre>"
    Response.End
End If

success = http.SetUrlVar("accountName",accountName)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Could not encode account name.") & "</pre>"
    Response.End
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
ERROR: ASP example cannot use request or response as a variable name.
    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
        Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response. Inspect LastErrorText privately; it may contain credentials.") & "</pre>"
        Response.End
    End If

    If ((response.StatusCode <> 200) And (response.StatusCode <> 202)) Then
        Response.Write "<pre>" & Server.HTMLEncode( "HTTP status: " & response.StatusCode) & "</pre>"
        Response.Write "<pre>" & Server.HTMLEncode( "Request ID: " & response.GetHeaderField("x-ms-request-id")) & "</pre>"
        Response.Write "<pre>" & Server.HTMLEncode( "Retry-After: " & response.GetHeaderField("Retry-After")) & "</pre>"
        '  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.
        Response.End
    End If

    If (success <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( "The HTTP response could not be read completely.") & "</pre>"
        Response.End
    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
            Response.Write "<pre>" & Server.HTMLEncode( "Accepted, but no monitor URL was returned. Check the resource; do not assume success.") & "</pre>"
            Response.End
        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
        Response.Write "<pre>" & Server.HTMLEncode( "Missing or invalid continuation URL.") & "</pre>"
        Response.End
    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
        Response.Write "<pre>" & Server.HTMLEncode( "Unexpected continuation URL; refusing to send the access token.") & "</pre>"
        Response.End
    End If

    Response.Write "<pre>" & Server.HTMLEncode( "Operation URL (save for resuming): " & operationUrl) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "operationUsesStatus: " & operationUsesStatus) & "</pre>"
    set retryText = Server.CreateObject("Chilkat.StringBuilder")
    set retryNumber = Server.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.
                Response.Write "<pre>" & Server.HTMLEncode( "Polling paused. Resume after Retry-After: " & retryAfter) & "</pre>"
                Response.End
            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
            Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response. Inspect LastErrorText privately; it may contain credentials.") & "</pre>"
            Response.End
        End If

        If ((response.StatusCode <> 200) And (response.StatusCode <> 202) And (response.StatusCode <> 204)) Then
            Response.Write "<pre>" & Server.HTMLEncode( "HTTP status: " & response.StatusCode) & "</pre>"
            Response.Write "<pre>" & Server.HTMLEncode( "Request ID: " & response.GetHeaderField("x-ms-request-id")) & "</pre>"
            Response.Write "<pre>" & Server.HTMLEncode( "Retry-After: " & response.GetHeaderField("Retry-After")) & "</pre>"
            '  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.
            Response.End
        End If

        If (success <> 1) Then
            Response.Write "<pre>" & Server.HTMLEncode( "The HTTP response could not be read completely.") & "</pre>"
            Response.End
        End If

        attempt = attempt + 1
        retryAfter = response.GetHeaderField("Retry-After")
        If (operationUsesStatus = 1) Then
            success = result.Load(response.BodyStr)
            If (success <> 1) Then
                Response.Write "<pre>" & Server.HTMLEncode( "Expected a well-formed JSON response.") & "</pre>"
                Response.End
            End If

            If ((result.JsonTypeOf("status") <> 1) Or (result.StringOfEquals("status","",1) = 1)) Then
                Response.Write "<pre>" & Server.HTMLEncode( "Expected a nonempty operation status.") & "</pre>"
                Response.End
            End If

            If ((result.StringOfEquals("status","Failed",1) = 1) Or (result.StringOfEquals("status","Canceled",1) = 1)) Then
                Response.Write "<pre>" & Server.HTMLEncode( "Provisioning did not succeed: " & result.StringOf("status")) & "</pre>"
                Response.Write "<pre>" & Server.HTMLEncode( "Error code: " & result.StringOf("error.code")) & "</pre>"
                Response.End
            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
        Response.Write "<pre>" & Server.HTMLEncode( "Polling limit reached; provisioning may still be running.") & "</pre>"
        Response.Write "<pre>" & Server.HTMLEncode( "Resume using the saved operation URL. Retry-After: " & retryAfter) & "</pre>"
        Response.End
    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
    Response.Write "<pre>" & Server.HTMLEncode( "No HTTP response. Inspect LastErrorText privately; it may contain credentials.") & "</pre>"
    Response.End
End If

If ((response.StatusCode <> 200)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "HTTP status: " & response.StatusCode) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "Request ID: " & response.GetHeaderField("x-ms-request-id")) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "Retry-After: " & response.GetHeaderField("Retry-After")) & "</pre>"
    '  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.
    Response.End
End If

If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "The HTTP response could not be read completely.") & "</pre>"
    Response.End
End If

success = result.Load(response.BodyStr)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Expected a well-formed JSON response.") & "</pre>"
    Response.End
End If

If (result.StringOfEquals("properties.provisioningState","Succeeded",1) <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Account is not confirmed ready. Provisioning state: " & result.StringOf("properties.provisioningState")) & "</pre>"
    '  If pending, GET this resource later; do not repeat PUT just to check status.
    Response.End
End If

If ((result.JsonTypeOf("id") <> 1) Or (result.StringOfEquals("id","",1) = 1)) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Expected the provisioned account's resource ID.") & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Storage account provisioning succeeded.") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Resource ID: " & result.StringOf("id")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Name: " & result.StringOf("name")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Blob endpoint: " & result.StringOf("properties.primaryEndpoints.blob")) & "</pre>"
'  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.

%>
</body>
</html>