PowerBuilder
PowerBuilder
Azure List Storage Accounts
See more Azure Storage Accounts Examples
Demonstrates how to list Azure storage accounts.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_JsonToken
string ls_Url
string ls_JsonResp
oleobject loo_Json
integer i
integer li_Count_i
string ls_SkuName
string ls_SkuTier
string ls_Kind
string ls_Id
string ls_Name
string ls_V_type
string ls_Location
string ls_PropertiesNetworkAclsBypass
string ls_PropertiesNetworkAclsDefaultAction
integer li_PropertiesSupportsHttpsTrafficOnly
integer li_PropertiesEncryptionServicesFileEnabled
string ls_PropertiesEncryptionServicesFileLastEnabledTime
integer li_PropertiesEncryptionServicesBlobEnabled
string ls_PropertiesEncryptionServicesBlobLastEnabledTime
string ls_PropertiesEncryptionKeySource
string ls_PropertiesProvisioningState
string ls_PropertiesCreationTime
string ls_PropertiesPrimaryEndpointsBlob
string ls_PropertiesPrimaryEndpointsQueue
string ls_PropertiesPrimaryEndpointsTable
string ls_PropertiesPrimaryEndpointsFile
string ls_PropertiesPrimaryLocation
string ls_PropertiesStatusOfPrimary
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// Load an OAuth2 access token previously fetched by this example: Get Azure OAuth2 Access Token
loo_JsonToken = create oleobject
li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject")
li_Success = loo_JsonToken.LoadFile("qa_data/tokens/azureToken.json")
// Assuming success..
loo_Http.AuthToken = loo_JsonToken.StringOf("access_token")
Write-Debug "AuthToken: " + loo_Http.AuthToken
loo_Http.Accept = "application/json"
ls_Url = "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts?api-version=2018-11-01"
ls_JsonResp = loo_Http.QuickGetStr(ls_Url)
if loo_Http.LastMethodSuccess <> 1 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_JsonToken
return
end if
Write-Debug "Response Status Code: " + string(loo_Http.LastStatus)
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.Load(ls_JsonResp)
loo_Json.EmitCompact = 0
Write-Debug loo_Json.Emit()
if loo_Http.LastStatus <> 200 then
Write-Debug "Failed."
destroy loo_Http
destroy loo_JsonToken
destroy loo_Json
return
end if
// 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"
// }
// }
// ]
// }
//
i = 0
li_Count_i = loo_Json.SizeOfArray("value")
do while i < li_Count_i
loo_Json.I = i
ls_SkuName = loo_Json.StringOf("value[i].sku.name")
ls_SkuTier = loo_Json.StringOf("value[i].sku.tier")
ls_Kind = loo_Json.StringOf("value[i].kind")
ls_Id = loo_Json.StringOf("value[i].id")
ls_Name = loo_Json.StringOf("value[i].name")
ls_V_type = loo_Json.StringOf("value[i].type")
ls_Location = loo_Json.StringOf("value[i].location")
ls_PropertiesNetworkAclsBypass = loo_Json.StringOf("value[i].properties.networkAcls.bypass")
ls_PropertiesNetworkAclsDefaultAction = loo_Json.StringOf("value[i].properties.networkAcls.defaultAction")
li_PropertiesSupportsHttpsTrafficOnly = loo_Json.BoolOf("value[i].properties.supportsHttpsTrafficOnly")
li_PropertiesEncryptionServicesFileEnabled = loo_Json.BoolOf("value[i].properties.encryption.services.file.enabled")
ls_PropertiesEncryptionServicesFileLastEnabledTime = loo_Json.StringOf("value[i].properties.encryption.services.file.lastEnabledTime")
li_PropertiesEncryptionServicesBlobEnabled = loo_Json.BoolOf("value[i].properties.encryption.services.blob.enabled")
ls_PropertiesEncryptionServicesBlobLastEnabledTime = loo_Json.StringOf("value[i].properties.encryption.services.blob.lastEnabledTime")
ls_PropertiesEncryptionKeySource = loo_Json.StringOf("value[i].properties.encryption.keySource")
ls_PropertiesProvisioningState = loo_Json.StringOf("value[i].properties.provisioningState")
ls_PropertiesCreationTime = loo_Json.StringOf("value[i].properties.creationTime")
ls_PropertiesPrimaryEndpointsBlob = loo_Json.StringOf("value[i].properties.primaryEndpoints.blob")
ls_PropertiesPrimaryEndpointsQueue = loo_Json.StringOf("value[i].properties.primaryEndpoints.queue")
ls_PropertiesPrimaryEndpointsTable = loo_Json.StringOf("value[i].properties.primaryEndpoints.table")
ls_PropertiesPrimaryEndpointsFile = loo_Json.StringOf("value[i].properties.primaryEndpoints.file")
ls_PropertiesPrimaryLocation = loo_Json.StringOf("value[i].properties.primaryLocation")
ls_PropertiesStatusOfPrimary = loo_Json.StringOf("value[i].properties.statusOfPrimary")
i = i + 1
loop
destroy loo_Http
destroy loo_JsonToken
destroy loo_Json