Create resource
In order to create or add Resources, we can get more idea and how to create it using this Azure Resource Manager Templates reference from microsoft:
https://docs.microsoft.com/en-us/azure/templates/
Below is a sample arm template json file which will create storage resource.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"name": "{provide-unique-name}",
"location": "eastus",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
]
}
Resource properties
Every resource you deploy has at least the following three properties:
- type: Type of the resource.
- apiVersion: Version of the REST API to use for creating the resource.
- name: Name of the resource.
- Location: Region where this resource will be created
Deploy template
You can deploy this arm template json file, you can use the below powershell script
New-AzResourceGroupDeployment `
-Name addstorage `
-ResourceGroupName myResourceGroup `
-TemplateFile $templateFile
Two possible deployment failures that you might encounter:
- Error: Code=AccountNameInvalid; Message={provide-unique-name} is not a valid storage account name. Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only.In the template, replace {provide-unique-name} with a unique storage account name. See Add resource.
- Error: Code=StorageAccountAlreadyTaken; Message=The storage account named store1abc09092019 is already taken.In the template, try a different storage account name.
Verify deployment
TO verify the deployment was successful, you can see while deploying thru PowerShell or going to Azure Portal as below:
- Sign in to the Azure portal.
- From the left menu, select Resource groups.
- Select the resource group you deployed to.
- You see that a storage account has been deployed.
- Notice that the deployment label now says: Deployments: 2 Succeeded.