Teach you how to create an azure ARM Template

Source: Internet
Author: User

Azure's arm model has landed in China. In arm mode, the creation of various resources through ARM's template batch is one of the biggest differences with ASM mode. The number of template modules for Azure arm is now increasing, and more customers will choose to use template mode for resource deployment:

As described in the previous article, how to modify the template you need by using the existing templates, please refer to:

Http://www.cnblogs.com/hengwei/p/5634380.html

This article creates an arm Template for the simplest storage account step-by-step, and deploys it to azure China.

A Preparation Tool

1 Download installation tools: Visual Studio Code

First download Visual Studio Code:

https://code.visualstudio.com/

This software is a simplified version of Visual Studio and is free of charge. and can support Windows, Mac, and Linux.

2 Installing the plug-in for arm:

Open visual Studio Code, "Extensions" in the leftmost point and enter azure after search in the search box:

where "Azure Resource Manager Tools" and "Armsnippet" are plugins for Azure ARM template. Click Install.

Click Enable to restart Visual Studio Code.

3 Configuring Visual Studio Code

From Link:

Https://raw.githubusercontent.com/Azure/azure-xplat-arm-tooling/master/VSCode/armsnippets.json

Copy the content and open it in Visual Studio code:

File->preferences->user Snippets:

Enter JSON and click JSON:

Copy the content that you just copied in {}:

Ctrl-s Close Visual Studio Code after saving.

Two prepare the resources to be created

This article will write the simplest JSON file for creating the store. If the customer wants to create a storage account, they need to prepare the following information:

1 storageaccountname:hwsa10

2 Storageaccounttype:standard_lrs

3 Resource Group: Using an already existing hwarm

?

Three writing JSON templates

1 Writing Azuredeploy.json files

Open Visual Studio Code, create a new file, and in the lower-right corner, click Plain Text input JSON:

2 Enter "Arm" in the editing area:

At this point, "Microsoft Azure resouce Manager (ARM) JSON Template structure" is prompted, press ENTER:

will appear:

{

"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",

"ContentVersion": "1.0.0.0",

"Parameters": {},

"Variables": {},

"Resources": [],

"Outputs": {}

}

Several parameters of the standard arm template.

3 Edit Parameter

Enter the relevant parameters in the parameter, and after entering "", Visual Studio code appears prompt:

These are the parameters that parameter can enter, where "type" is a required option. The prompt will appear each time you enter "" during the input process:

Input the "Storageaccountname" and "Storageaccounttype" prepared in front of you into parameter.

"Parameters": {

"Storageaccountname": {"type": "String"},

"Storageaccounttype": {

' Type ': ' String ',

"DefaultValue": "Standard_lrs",

"Allowedvalues": [

"Standard_lrs",

"Standard_grs",

"Premium_lrs"

]

}

},

Enter Resource content:

After entering "", a prompt appears, where apiversion, location, propertises, type, name are required:

Again, each time you enter "" You will be prompted:

Results entered:

{

"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",

"ContentVersion": "1.0.0.0",

"Parameters": {

"Storageaccountname": {"type": "String"},

"Storageaccounttype": {

' Type ': ' String ',

"DefaultValue": "Standard_lrs",

"Allowedvalues": [

"Standard_lrs",

"Standard_grs",

"Premium_lrs"

]

}

},

"Variables": {},

"Resources": [

{

"Type": "Microsoft.storage/storageaccounts",

"Name": "[Parameters (' Storageaccountname ')]",

"Apiversion": "2015-06-15",

"Location": "[ResourceGroup (). Location]",

"Properties": {

"AccountType": "[Parameters (' Storageaccounttype ')]"

}

?

}

],

"Outputs": {}

}

Quad Edit parameter file

According to the existing parameter file, fill in the two parameters defined above:

{

"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",

"ContentVersion": "1.0.0.0",

"Parameters": {

"Storageaccountname": {

"Value": "Hwsa01"

},

"Storageaccounttype": {

"Value": "Standard_lrs"

}

}

}

At this point, two files have been edited and completed.

This template can then be published to Azure via PowerShell, creating a storageaccount.

PS c:\users\hengz> new-azurermresourcegroupdeployment-name hwarmtemplate-resourcegroupname Hwarm-mode Incremental-templatefile D:\AzureDeploy.json-TemplateParameterFile D:\DeployParameterFile.json

?

?

Deploymentname:hwarmtemplate

Resourcegroupname:hwarm

provisioningstate:succeeded

TIMESTAMP:2016/9/9 13:29:53

Mode:incremental

Templatelink:

Parameters:

Name Type Value

=============== ========================= ==========

Storageaccountname String hwsa10

Storageaccounttype String Standard_lrs

?

Outputs:

Deploymentdebugloglevel:

?

Teach you how to create an azure ARM Template

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.