AutoIt
AutoIt
Azure List Storage Accounts
See more Azure Storage Accounts Examples
Demonstrates how to list Azure storage accounts.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
; Load an OAuth2 access token previously fetched by this example: Get Azure OAuth2 Access Token
$oJsonToken = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oJsonToken.LoadFile("qa_data/tokens/azureToken.json")
; Assuming success..
$oHttp.AuthToken = $oJsonToken.StringOf("access_token")
ConsoleWrite("AuthToken: " & $oHttp.AuthToken & @CRLF)
$oHttp.Accept = "application/json"
Local $sUrl = "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts?api-version=2018-11-01"
Local $sJsonResp = $oHttp.QuickGetStr($sUrl)
If ($oHttp.LastMethodSuccess <> True) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Response Status Code: " & $oHttp.LastStatus & @CRLF)
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.Load($sJsonResp)
$oJson.EmitCompact = False
ConsoleWrite($oJson.Emit() & @CRLF)
If ($oHttp.LastStatus <> 200) Then
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; Sample output...
; (See the parsing code below..)
;
; Use this online tool to generate parsing code from sample JSON:
; Generate Parsing Code from JSON
; {
; "value": [
; {
; "sku": {
; "name": "Standard_LRS",
; "tier": "Standard"
; },
; "kind": "Storage",
; "id": "/subscriptions/6c42643b-ebef-45e0-b917-b3583b84a57f/resourceGroups/gchilkat/providers/Microsoft.Storage/storageAccounts/chilkat",
; "name": "chilkat",
; "type": "Microsoft.Storage/storageAccounts",
; "location": "eastus",
; "tags": {},
; "properties": {
; "networkAcls": {
; "bypass": "AzureServices",
; "virtualNetworkRules": [
; ],
; "ipRules": [
; ],
; "defaultAction": "Allow"
; },
; "supportsHttpsTrafficOnly": true,
; "encryption": {
; "services": {
; "file": {
; "enabled": true,
; "lastEnabledTime": "2017-12-28T11:02:10.6840887Z"
; },
; "blob": {
; "enabled": true,
; "lastEnabledTime": "2017-12-28T11:02:10.6840887Z"
; }
; },
; "keySource": "Microsoft.Storage"
; },
; "provisioningState": "Succeeded",
; "creationTime": "2016-04-18T22:57:36.5377065Z",
; "primaryEndpoints": {
; "blob": "https://chilkat.blob.core.windows.net/",
; "queue": "https://chilkat.queue.core.windows.net/",
; "table": "https://chilkat.table.core.windows.net/",
; "file": "https://chilkat.file.core.windows.net/"
; },
; "primaryLocation": "eastus",
; "statusOfPrimary": "available"
; }
; }
; ]
; }
;
Local $i
Local $iCount_i
Local $skuName
Local $skuTier
Local $sKind
Local $sId
Local $sName
Local $sV_type
Local $sLocation
Local $sPropertiesNetworkAclsBypass
Local $sPropertiesNetworkAclsDefaultAction
Local $bPropertiesSupportsHttpsTrafficOnly
Local $bPropertiesEncryptionServicesFileEnabled
Local $sPropertiesEncryptionServicesFileLastEnabledTime
Local $bPropertiesEncryptionServicesBlobEnabled
Local $sPropertiesEncryptionServicesBlobLastEnabledTime
Local $sPropertiesEncryptionKeySource
Local $sPropertiesProvisioningState
Local $sPropertiesCreationTime
Local $sPropertiesPrimaryEndpointsBlob
Local $sPropertiesPrimaryEndpointsQueue
Local $sPropertiesPrimaryEndpointsTable
Local $sPropertiesPrimaryEndpointsFile
Local $sPropertiesPrimaryLocation
Local $sPropertiesStatusOfPrimary
$i = 0
$iCount_i = $oJson.SizeOfArray("value")
While $i < $iCount_i
$oJson.I = $i
$skuName = $oJson.StringOf("value[i].sku.name")
$skuTier = $oJson.StringOf("value[i].sku.tier")
$sKind = $oJson.StringOf("value[i].kind")
$sId = $oJson.StringOf("value[i].id")
$sName = $oJson.StringOf("value[i].name")
$sV_type = $oJson.StringOf("value[i].type")
$sLocation = $oJson.StringOf("value[i].location")
$sPropertiesNetworkAclsBypass = $oJson.StringOf("value[i].properties.networkAcls.bypass")
$sPropertiesNetworkAclsDefaultAction = $oJson.StringOf("value[i].properties.networkAcls.defaultAction")
$bPropertiesSupportsHttpsTrafficOnly = $oJson.BoolOf("value[i].properties.supportsHttpsTrafficOnly")
$bPropertiesEncryptionServicesFileEnabled = $oJson.BoolOf("value[i].properties.encryption.services.file.enabled")
$sPropertiesEncryptionServicesFileLastEnabledTime = $oJson.StringOf("value[i].properties.encryption.services.file.lastEnabledTime")
$bPropertiesEncryptionServicesBlobEnabled = $oJson.BoolOf("value[i].properties.encryption.services.blob.enabled")
$sPropertiesEncryptionServicesBlobLastEnabledTime = $oJson.StringOf("value[i].properties.encryption.services.blob.lastEnabledTime")
$sPropertiesEncryptionKeySource = $oJson.StringOf("value[i].properties.encryption.keySource")
$sPropertiesProvisioningState = $oJson.StringOf("value[i].properties.provisioningState")
$sPropertiesCreationTime = $oJson.StringOf("value[i].properties.creationTime")
$sPropertiesPrimaryEndpointsBlob = $oJson.StringOf("value[i].properties.primaryEndpoints.blob")
$sPropertiesPrimaryEndpointsQueue = $oJson.StringOf("value[i].properties.primaryEndpoints.queue")
$sPropertiesPrimaryEndpointsTable = $oJson.StringOf("value[i].properties.primaryEndpoints.table")
$sPropertiesPrimaryEndpointsFile = $oJson.StringOf("value[i].properties.primaryEndpoints.file")
$sPropertiesPrimaryLocation = $oJson.StringOf("value[i].properties.primaryLocation")
$sPropertiesStatusOfPrimary = $oJson.StringOf("value[i].properties.statusOfPrimary")
$i = $i + 1
Wend