Understanding Logic Apps Arm Templates
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "storageName": { "type": "string", "minLength": 3, "maxLength": 24 }, "storageSKU": { "type": "string", "defaultValue": "Standard_LRS", "allowedValues": [ "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS" ] } }, "resources": [ { "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2019-04-01", "name": "[parameters('storageName')]", "location": "eastus", "sku": { "name": "[parameters('storageSKU')]" }, "kind": "StorageV2", "properties": { "supportsHttpsTrafficOnly": true } } ]}
The storageSKU parameter
has a default value. This value is used when a value isn't specified during the
deployment. It also has a list of allowed values. These values match the values
that are needed to create a storage account. You don't want users of your
template to pass in SKUs that don't work.
Use variable
The following example highlights the changes to add a
variable to your template that creates a unique storage account name. Copy the
whole file and replace your template with its contents.
JSONCopy
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storagePrefix": {
"type": "string",
"minLength": 3,
"maxLength": 11
},
"storageSKU": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS",
"Standard_ZRS",
"Premium_LRS",
"Premium_ZRS",
"Standard_GZRS",
"Standard_RAGZRS"
]
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
}
},
"variables": {
"uniqueStorageName": "[concat(parameters('storagePrefix'),
uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"name": "[variables('uniqueStorageName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageSKU')]"
},
"kind": "StorageV2",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
]
}
Notice that it includes a variable named uniqueStorageName.
This variable uses four functions to construct a string value.
How to Add Function…
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageName": {
"type": "string",
"minLength": 3,
"maxLength": 24
},
"storageSKU": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS",
]
},
"location": { "type":
"string", "defaultValue":
"[resourceGroup().location]" }
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"name": "[parameters('storageName')]",
"location":
"[parameters('location')]",
"sku": {
"name": "[parameters('storageSKU')]"
},
"kind": "StorageV2",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
]
}
Add outputs
You can use outputs to return values from the
template. For example, it might be helpful to get the endpoints for your new
storage account.The following example highlights the change to your template to
add an output value. Copy the whole file and replace your template with its
contents.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storagePrefix": {
"type": "string",
"minLength": 3,
"maxLength": 11
},
"storageSKU": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS",
"Standard_ZRS",
"Premium_LRS",
"Premium_ZRS",
"Standard_GZRS",
"Standard_RAGZRS"
]
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
}
},
"variables": {
"uniqueStorageName": "[concat(parameters('storagePrefix'),
uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-04-01",
"name": "[variables('uniqueStorageName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageSKU')]"
},
"kind": "StorageV2",
"properties": {
"supportsHttpsTrafficOnly": true
}
}
],
"outputs": {
"storageEndpoint": {
"type": "object",
"value": "[reference(variables('uniqueStorageName')).primaryEndpoints]"
}
}
}
There are some important items to note about the
output value you added. The type of returned value is set to object,
which means it returns a JSON object. It uses the reference function to get
the runtime state of the storage account. To get the runtime state of a
resource, you pass in the name or ID of a resource. In this case, you use the
same variable you used to create the name of the storage account. Finally, it
returns the primaryEndpoints property from the storage account
Deploy the template
Open the integrated Visual Studio Code terminal using
the ctrl + ` key combination and use either the
Azure CLI or Azure PowerShell module to deploy the template.
Deploy template
You're ready to deploy the template and look at the
returned value.
New-AzResourceGroupDeployment `
-Name
addoutputs `
-ResourceGroupName myResourceGroup `
-TemplateFile $templateFile `
-storagePrefix "store" `
-storageSKU
Standard_LRS
In the output for the deployment command, you'll see
an object similar to the following example only if the output is in JSON format:
{
"dfs": "https://storeluktbfkpjjrkm.dfs.core.windows.net/",
"web": "https://storeluktbfkpjjrkm.z19.web.core.windows.net/",
"blob": "https://storeluktbfkpjjrkm.blob.core.windows.net/",
"queue": "https://storeluktbfkpjjrkm.queue.core.windows.net/",
"table": "https://storeluktbfkpjjrkm.table.core.windows.net/",
"file": "https://storeluktbfkpjjrkm.file.core.windows.net/"
}
az deployment group create
--resource-group arm-vscode
--template-file azuredeploy.json
--parameters
azuredeploy.parameters.json
Clean up resources
When the Azure resources are no longer needed, use the
Azure CLI or Azure PowerShell module to delete the resource group.
az group delete
--name arm-vscode
How
to Deploy Logic Apps Solution…
When you create Logic Apps project you will get by defaults power shell script and a logic app json file Which will have below sections..
Step1:
As per recommendation develop your logic App
into portal itself first and test it. Save/download json file of logic app..
Step2:
Create a
project in visual studio using logic app template then copy that Json file
Under resources expand it you have a place
holder this is where you have to place your logic App code.
What is Azure Resource Manager Template..
Azure Resource Manager allows you to
provision your applications using a declarative template. In a single template,
you can deploy multiple services along with their dependencies. You use the
same template to repeatedly deploy your application during every stage of the
application life cycle.There are many predefined templates available for use
please refers below link as per your requirement you can add into your project…
https://azure.microsoft.com/en-gb/resources/templates/
Create Storage Account and Blob Container
|
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", |
|
|
"contentVersion": "1.0.0.0", |
|
|
"parameters": { |
|
|
"storageAccountName": { |
|
|
"type": "string", |
|
|
"metadata": { |
|
|
"description": "Specifies the name
of the Azure Storage account." |
|
|
} |
|
|
}, |
|
|
"containerName": { |
|
|
"type": "string", |
|
|
"defaultValue": "logs", |
|
|
"metadata": { |
|
|
"description": "Specifies the name
of the blob container." |
|
|
} |
|
|
}, |
|
|
"location": { |
|
|
"type": "string", |
|
|
"defaultValue": "[resourceGroup().location]", |
|
|
"metadata": { |
|
|
"description": "Specifies the
location in which the Azure Storage resources should be deployed." |
|
|
} |
|
|
} |
|
|
}, |
|
|
"resources": [ |
|
|
{ |
|
|
"type": "Microsoft.Storage/storageAccounts", |
|
|
"apiVersion": "2019-06-01", |
|
|
"name": "[parameters('storageAccountName')]", |
|
|
"location": "[parameters('location')]", |
|
|
"sku": { |
|
|
"name": "Standard_LRS", |
|
|
"tier": "Standard" |
|
|
}, |
|
|
"kind": "StorageV2", |
|
|
"properties": { |
|
|
"accessTier": "Hot" |
|
|
}, |
|
|
"resources": [ |
|
|
{ |
|
|
"type": "blobServices/containers", |
|
|
"apiVersion": "2019-06-01", |
|
|
"name": "[concat('default/',
parameters('containerName'))]", |
|
|
"dependsOn": [ |
|
|
"[parameters('storageAccountName')]" |
|
|
] |
|
|
} |
|
|
] |
|
|
} |
|
|
] |
|
|
} |
Will post nested template in next blog..
ReplyDelete