Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Azure Create Storage AccountDemonstrates how to create an Azure storage account.
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Token Handle hoJsonToken Boolean iSuccess RequestBody Handle hoJsonRequestBody String sUrl Variant vResp Handle hoResp Handle hoJson String sSkuName String sSkuTier String sKind String sId String sName String sV_type String sLocation String sPropertiesNetworkAclsBypass String sPropertiesNetworkAclsDefaultAction Boolean iPropertiesSupportsHttpsTrafficOnly Boolean iPropertiesEncryptionServicesFileEnabled String sPropertiesEncryptionServicesFileLastEnabledTime Boolean iPropertiesEncryptionServicesBlobEnabled String sPropertiesEncryptionServicesBlobLastEnabledTime String sPropertiesEncryptionKeySource String sPropertiesAccessTier String sPropertiesProvisioningState String sPropertiesCreationTime String sPropertiesPrimaryEndpointsDfs String sPropertiesPrimaryEndpointsWeb String sPropertiesPrimaryEndpointsBlob String sPropertiesPrimaryEndpointsQueue String sPropertiesPrimaryEndpointsTable String sPropertiesPrimaryEndpointsFile String sPropertiesPrimaryLocation String sPropertiesStatusOfPrimary String sPropertiesSecondaryLocation String sPropertiesStatusOfSecondary Integer i Integer iCount_i String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // Load an OAuth2 access token previously fetched by this example: Get Azure OAuth2 Access Token Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken If (Not(IsComObjectCreated(hoJsonToken))) Begin Send CreateComObject of hoJsonToken End Get ComLoadFile Of hoJsonToken "qa_data/tokens/azureToken.json" To iSuccess // Assuming success.. Get ComStringOf Of hoJsonToken "access_token" To sTemp1 Set ComAuthToken Of hoHttp To sTemp1 Get ComAuthToken Of hoHttp To sTemp1 Showln "AuthToken: " sTemp1 Set ComAccept Of hoHttp To "application/json" // Create the following JSON: // { // "sku": { // "name": "Standard_GRS" // }, // "kind": "StorageV2", // "location": "eastus2", // } // Use this online tool to generate the code from sample JSON: // Generate Code to Create JSON Get Create (RefClass(cComChilkatJsonObject)) To hoJsonRequestBody If (Not(IsComObjectCreated(hoJsonRequestBody))) Begin Send CreateComObject of hoJsonRequestBody End Get ComUpdateString Of hoJsonRequestBody "sku.name" "Standard_GRS" To iSuccess Get ComUpdateString Of hoJsonRequestBody "kind" "StorageV2" To iSuccess Get ComUpdateString Of hoJsonRequestBody "location" "eastus2" To iSuccess Move "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}?api-version=2018-02-01" To sUrl Get ComEmit Of hoJsonRequestBody To sTemp1 Get ComPText Of hoHttp "PUT" sUrl sTemp1 "utf-8" "application/json" False False To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get ComStatusCode Of hoResp To iTemp1 Showln "Response Status Code: " iTemp1 Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComBodyStr Of hoResp To sTemp1 Get ComLoad Of hoJson sTemp1 To iSuccess Set ComEmitCompact Of hoJson To False Get ComEmit Of hoJson To sTemp1 Showln sTemp1 Get ComStatusCode Of hoResp To iTemp1 If (iTemp1 >= 300) Begin Showln "Failed." Send Destroy of hoResp Procedure_Return End // Successful requests to create a new account return a 202 status code with an empty response body. The storage account is created asynchronously. // If the account already exists or is being provisioned, the request response has a 200 return code with the configuration of the existing storage account in the response body. Get ComStatusCode Of hoResp To iTemp1 If (iTemp1 = 202) Begin Get ComGetHeaderField Of hoResp "Azure-AsyncOperation" To sTemp1 Showln "Azure-AsyncOperation: " sTemp1 End Get ComStatusCode Of hoResp To iTemp1 If (iTemp1 = 200) Begin // Parse a response like this: // { // "sku": { // "name": "Standard_GRS", // "tier": "Standard" // }, // "kind": "StorageV2", // "id": "/subscriptions/6c42643b-ebef-45f0-b917-b3583b84a57f/resourceGroups/gChilkat/providers/Microsoft.Storage/storageAccounts/chilkatsoftware", // "name": "chilkatsoftware", // "type": "Microsoft.Storage/storageAccounts", // "location": "eastus2", // "tags": {}, // "properties": { // "networkAcls": { // "bypass": "AzureServices", // "virtualNetworkRules": [ // ], // "ipRules": [ // ], // "defaultAction": "Allow" // }, // "supportsHttpsTrafficOnly": false, // "encryption": { // "services": { // "file": { // "enabled": true, // "lastEnabledTime": "2019-05-14T22:18:33.2246670Z" // }, // "blob": { // "enabled": true, // "lastEnabledTime": "2019-05-14T22:18:33.2246670Z" // } // }, // "keySource": "Microsoft.Storage" // }, // "accessTier": "Hot", // "provisioningState": "Succeeded", // // "creationTime": "2019-05-14T22:18:33.1309165Z", // "primaryEndpoints": { // "dfs": "https://chilkatsoftware.dfs.core.windows.net/", // "web": "https://chilkatsoftware.z20.web.core.windows.net/", // "blob": "https://chilkatsoftware.blob.core.windows.net/", // "queue": "https://chilkatsoftware.queue.core.windows.net/", // "table": "https://chilkatsoftware.table.core.windows.net/", // "file": "https://chilkatsoftware.file.core.windows.net/" // }, // "primaryLocation": "eastus2", // "statusOfPrimary": "available", // "secondaryLocation": "centralus", // "statusOfSecondary": "available" // } // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON Get ComStringOf Of hoJson "sku.name" To sSkuName Get ComStringOf Of hoJson "sku.tier" To sSkuTier Get ComStringOf Of hoJson "kind" To sKind Get ComStringOf Of hoJson "id" To sId Get ComStringOf Of hoJson "name" To sName Get ComStringOf Of hoJson "type" To sV_type Get ComStringOf Of hoJson "location" To sLocation Get ComStringOf Of hoJson "properties.networkAcls.bypass" To sPropertiesNetworkAclsBypass Get ComStringOf Of hoJson "properties.networkAcls.defaultAction" To sPropertiesNetworkAclsDefaultAction Get ComBoolOf Of hoJson "properties.supportsHttpsTrafficOnly" To iPropertiesSupportsHttpsTrafficOnly Get ComBoolOf Of hoJson "properties.encryption.services.file.enabled" To iPropertiesEncryptionServicesFileEnabled Get ComStringOf Of hoJson "properties.encryption.services.file.lastEnabledTime" To sPropertiesEncryptionServicesFileLastEnabledTime Get ComBoolOf Of hoJson "properties.encryption.services.blob.enabled" To iPropertiesEncryptionServicesBlobEnabled Get ComStringOf Of hoJson "properties.encryption.services.blob.lastEnabledTime" To sPropertiesEncryptionServicesBlobLastEnabledTime Get ComStringOf Of hoJson "properties.encryption.keySource" To sPropertiesEncryptionKeySource Get ComStringOf Of hoJson "properties.accessTier" To sPropertiesAccessTier Get ComStringOf Of hoJson "properties.provisioningState" To sPropertiesProvisioningState Get ComStringOf Of hoJson "properties.creationTime" To sPropertiesCreationTime Get ComStringOf Of hoJson "properties.primaryEndpoints.dfs" To sPropertiesPrimaryEndpointsDfs Get ComStringOf Of hoJson "properties.primaryEndpoints.web" To sPropertiesPrimaryEndpointsWeb Get ComStringOf Of hoJson "properties.primaryEndpoints.blob" To sPropertiesPrimaryEndpointsBlob Get ComStringOf Of hoJson "properties.primaryEndpoints.queue" To sPropertiesPrimaryEndpointsQueue Get ComStringOf Of hoJson "properties.primaryEndpoints.table" To sPropertiesPrimaryEndpointsTable Get ComStringOf Of hoJson "properties.primaryEndpoints.file" To sPropertiesPrimaryEndpointsFile Get ComStringOf Of hoJson "properties.primaryLocation" To sPropertiesPrimaryLocation Get ComStringOf Of hoJson "properties.statusOfPrimary" To sPropertiesStatusOfPrimary Get ComStringOf Of hoJson "properties.secondaryLocation" To sPropertiesSecondaryLocation Get ComStringOf Of hoJson "properties.statusOfSecondary" To sPropertiesStatusOfSecondary End Showln "Success." Send Destroy of hoResp End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.