Chilkat • HOME • Android™ • AutoIt • C • C# • C++ • Chilkat2-Python • CkPython • Classic ASP • DataFlex • Delphi DLL • Go • Java • Node.js • Objective-C • PHP Extension • Perl • PowerBuilder • PowerShell • PureBasic • Ruby • SQL Server • Swift • Tcl • Unicode C • Unicode C++ • VB.NET • VBScript • Visual Basic 6.0 • Visual FoxPro • Xojo Plugin
(Delphi DLL) Azure List Storage AccountsDemonstrates how to list Azure storage accounts.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, JsonObject, Http; ... procedure TForm1.Button1Click(Sender: TObject); var http: HCkHttp; jsonToken: HCkJsonObject; success: Boolean; url: PWideChar; jsonResp: PWideChar; json: HCkJsonObject; i: Integer; count_i: Integer; skuName: PWideChar; skuTier: PWideChar; kind: PWideChar; id: PWideChar; name: PWideChar; v_type: PWideChar; location: PWideChar; propertiesNetworkAclsBypass: PWideChar; propertiesNetworkAclsDefaultAction: PWideChar; propertiesSupportsHttpsTrafficOnly: Boolean; propertiesEncryptionServicesFileEnabled: Boolean; propertiesEncryptionServicesFileLastEnabledTime: PWideChar; propertiesEncryptionServicesBlobEnabled: Boolean; propertiesEncryptionServicesBlobLastEnabledTime: PWideChar; propertiesEncryptionKeySource: PWideChar; propertiesProvisioningState: PWideChar; propertiesCreationTime: PWideChar; propertiesPrimaryEndpointsBlob: PWideChar; propertiesPrimaryEndpointsQueue: PWideChar; propertiesPrimaryEndpointsTable: PWideChar; propertiesPrimaryEndpointsFile: PWideChar; propertiesPrimaryLocation: PWideChar; propertiesStatusOfPrimary: PWideChar; begin // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http := CkHttp_Create(); // Load an OAuth2 access token previously fetched by this example: Get Azure OAuth2 Access Token jsonToken := CkJsonObject_Create(); success := CkJsonObject_LoadFile(jsonToken,'qa_data/tokens/azureToken.json'); // Assuming success.. CkHttp_putAuthToken(http,CkJsonObject__stringOf(jsonToken,'access_token')); Memo1.Lines.Add('AuthToken: ' + CkHttp__authToken(http)); CkHttp_putAccept(http,'application/json'); url := 'https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts?api-version=2018-11-01'; jsonResp := CkHttp__quickGetStr(http,url); if (CkHttp_getLastMethodSuccess(http) <> True) then begin Memo1.Lines.Add(CkHttp__lastErrorText(http)); Exit; end; Memo1.Lines.Add('Response Status Code: ' + IntToStr(CkHttp_getLastStatus(http))); json := CkJsonObject_Create(); CkJsonObject_Load(json,jsonResp); CkJsonObject_putEmitCompact(json,False); Memo1.Lines.Add(CkJsonObject__emit(json)); if (CkHttp_getLastStatus(http) <> 200) then begin Memo1.Lines.Add('Failed.'); Exit; end; // 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; count_i := CkJsonObject_SizeOfArray(json,'value'); while i < count_i do begin CkJsonObject_putI(json,i); skuName := CkJsonObject__stringOf(json,'value[i].sku.name'); skuTier := CkJsonObject__stringOf(json,'value[i].sku.tier'); kind := CkJsonObject__stringOf(json,'value[i].kind'); id := CkJsonObject__stringOf(json,'value[i].id'); name := CkJsonObject__stringOf(json,'value[i].name'); v_type := CkJsonObject__stringOf(json,'value[i].type'); location := CkJsonObject__stringOf(json,'value[i].location'); propertiesNetworkAclsBypass := CkJsonObject__stringOf(json,'value[i].properties.networkAcls.bypass'); propertiesNetworkAclsDefaultAction := CkJsonObject__stringOf(json,'value[i].properties.networkAcls.defaultAction'); propertiesSupportsHttpsTrafficOnly := CkJsonObject_BoolOf(json,'value[i].properties.supportsHttpsTrafficOnly'); propertiesEncryptionServicesFileEnabled := CkJsonObject_BoolOf(json,'value[i].properties.encryption.services.file.enabled'); propertiesEncryptionServicesFileLastEnabledTime := CkJsonObject__stringOf(json,'value[i].properties.encryption.services.file.lastEnabledTime'); propertiesEncryptionServicesBlobEnabled := CkJsonObject_BoolOf(json,'value[i].properties.encryption.services.blob.enabled'); propertiesEncryptionServicesBlobLastEnabledTime := CkJsonObject__stringOf(json,'value[i].properties.encryption.services.blob.lastEnabledTime'); propertiesEncryptionKeySource := CkJsonObject__stringOf(json,'value[i].properties.encryption.keySource'); propertiesProvisioningState := CkJsonObject__stringOf(json,'value[i].properties.provisioningState'); propertiesCreationTime := CkJsonObject__stringOf(json,'value[i].properties.creationTime'); propertiesPrimaryEndpointsBlob := CkJsonObject__stringOf(json,'value[i].properties.primaryEndpoints.blob'); propertiesPrimaryEndpointsQueue := CkJsonObject__stringOf(json,'value[i].properties.primaryEndpoints.queue'); propertiesPrimaryEndpointsTable := CkJsonObject__stringOf(json,'value[i].properties.primaryEndpoints.table'); propertiesPrimaryEndpointsFile := CkJsonObject__stringOf(json,'value[i].properties.primaryEndpoints.file'); propertiesPrimaryLocation := CkJsonObject__stringOf(json,'value[i].properties.primaryLocation'); propertiesStatusOfPrimary := CkJsonObject__stringOf(json,'value[i].properties.statusOfPrimary'); i := i + 1; end; CkHttp_Dispose(http); CkJsonObject_Dispose(jsonToken); CkJsonObject_Dispose(json); end; |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.