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

Azure Storage Accounts: Update Storage Account Security Settings

See more Azure Storage Accounts Examples

PATCHes HTTPS-only, minimum TLS 1.2, anonymous blob access, and Shared Key policy without sending unrelated account properties. The default in this example disables Shared Key access. Review existing clients and key-signed SAS dependencies first; set allowSharedKey deliberately. This does not assign data-plane roles or configure network access. The TLS property controls requests to storage services, not the protocol version forced on Chilkat.Http.

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 Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

'  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.
Dim token As New ChilkatJsonObject
token.Strict = 1
success = token.LoadFile("qa_data/tokens/azureToken.json")
If (success <> 1) Then
    Debug.Print "Could not load the private Azure Resource Manager token file."
    Exit Sub
End If

If ((token.JsonTypeOf("access_token") <> 1) Or (token.StringOfEquals("access_token","",1) = 1)) Then
    Debug.Print "A nonempty access_token string is required."
    Exit Sub
End If

'  Use your subscription ID as a string. The all-zero value is only a placeholder.
Dim subscriptionId As String
subscriptionId = "00000000-0000-0000-0000-000000000000"
Dim http As New ChilkatHttp
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
    Debug.Print "Could not encode subscription ID."
    Exit Sub
End If

Dim response As New ChilkatHttpResponse
Dim result As New ChilkatJsonObject
result.Strict = 1
Dim parsed As New ChilkatUrl
Dim resourceGroupName As String
resourceGroupName = "my-resource-group"
success = http.SetUrlVar("resourceGroupName",resourceGroupName)
If (success <> 1) Then
    Debug.Print "Could not encode resource group."
    Exit Sub
End If

Dim accountName As String
accountName = "youruniquestorageaccount"
success = http.SetUrlVar("accountName",accountName)
If (success <> 1) Then
    Debug.Print "Could not encode account name."
    Exit Sub
End If

Dim resourceUrl As String
resourceUrl = "https://management.azure.com/subscriptions/{$subscriptionId}/resourceGroups/{$resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{$accountName}?api-version=2026-09-01"

'  Explicit policy choice: false disables account-key and key-signed SAS access.
'  Set true if existing clients must continue using Shared Key.
Dim allowSharedKey As Long
allowSharedKey = 0
Dim request As New ChilkatJsonObject
success = request.UpdateBool("properties.supportsHttpsTrafficOnly",1)
success = request.UpdateString("properties.minimumTlsVersion","TLS1_2")
success = request.UpdateBool("properties.allowBlobPublicAccess",0)
success = request.UpdateBool("properties.allowSharedKeyAccess",allowSharedKey)
'  This changes account access policy. Review client compatibility before running.
'  On a write timeout, read the resource before deciding whether to retry.
success = http.HttpJson("PATCH",resourceUrl,request,"application/json",response)
If (response.StatusCode = 0) Then
    Debug.Print "No HTTP response. Inspect LastErrorText privately; it may contain credentials."
    Exit Sub
End If

If ((response.StatusCode <> 200)) Then
    Debug.Print "HTTP status: " & response.StatusCode
    Debug.Print "Request ID: " & response.GetHeaderField("x-ms-request-id")
    Debug.Print "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.
    Exit Sub
End If

If (success <> 1) Then
    Debug.Print "The HTTP response could not be read completely."
    Exit Sub
End If

success = result.Load(response.BodyStr)
If (success <> 1) Then
    Debug.Print "Expected a well-formed JSON response."
    Exit Sub
End If

'  Check the returned policy rather than inferring it from HTTP status alone.
If ((result.BoolOf("properties.supportsHttpsTrafficOnly") <> 1) Or (result.StringOfEquals("properties.minimumTlsVersion","TLS1_2",1) <> 1) Or (result.JsonTypeOf("properties.allowBlobPublicAccess") <> 5) Or (result.BoolOf("properties.allowBlobPublicAccess") <> 0) Or (result.JsonTypeOf("properties.allowSharedKeyAccess") <> 5) Or (result.BoolOf("properties.allowSharedKeyAccess") <> allowSharedKey)) Then
    Debug.Print "Update returned unexpected policy values. Read the account before retrying."
    Exit Sub
End If

Debug.Print "Account security settings updated."