Skip to content

Instantly share code, notes, and snippets.

@Azadehkhojandi
Last active March 2, 2020 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Azadehkhojandi/b7ad485f7599cc08a45d37b64eab26d4 to your computer and use it in GitHub Desktop.
Save Azadehkhojandi/b7ad485f7599cc08a45d37b64eab26d4 to your computer and use it in GitHub Desktop.
A sample that creates one storage account and one azure function and it's dependent resources (app insights, storage, ...)
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",
"handler": "Microsoft.Azure.CreateUIDef",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{}
],
"steps": [
{
"name": "storageConfig",
"label": "Storage settings",
"subLabel": {
"preValidation": "Configure the infrastructure settings",
"postValidation": "Done"
},
"bladeTitle": "Storage settings",
"elements": [
{
"name": "storageAccounts",
"type": "Microsoft.Storage.MultiStorageAccountCombo",
"label": {
"prefix": "Storage account name prefix",
"type": "Storage account type"
},
"defaultValue": {
"type": "Standard_LRS"
},
"constraints": {
"allowedTypes": [
"Premium_LRS",
"Standard_LRS",
"Standard_GRS"
]
}
}
]
},
{
"name": "azfuncConfig",
"label": "AzureFunc settings",
"subLabel": {
"preValidation": "Configure the infrastructure settings",
"postValidation": "Done"
},
"bladeTitle": "AzureFunc settings",
"elements": [
{
"name": "storageAccounts",
"type": "Microsoft.Storage.MultiStorageAccountCombo",
"label": {
"prefix": "Storage account name",
"type": "Storage account type"
},
"defaultValue": {
"type": "Standard_LRS"
},
"constraints": {
"allowedTypes": [
"Premium_LRS",
"Standard_LRS",
"Standard_GRS"
]
}
},
{
"name": "runtime",
"type": "Microsoft.Common.DropDown",
"label": "The language worker runtime",
"defaultValue": "node",
"toolTip": "The language worker runtime to load in the function app.",
"constraints": {
"allowedValues": [
{
"label": "node",
"value": "node"
},
{
"label": "dotnet",
"value": "dotnet"
},
{
"label": "java",
"value": "java"
}
],
"required": true
},
"visible": true
},
{
"name": "appName",
"type": "Microsoft.Common.TextBox",
"label": "function app name",
"defaultValue": "myfuncapp",
"toolTip": "The name of the function app that you wish to create.",
"constraints": {
"required": true,
"regex": "^[a-z0-9A-Z]{1,30}$",
"validationMessage": "Only alphanumeric characters are allowed, and the value must be 1-30 characters long."
},
"visible": true
}
]
}
],
"outputs": {
"storageAccountNamePrefix": "[steps('storageConfig').storageAccounts.prefix]",
"storageAccountType": "[steps('storageConfig').storageAccounts.type]",
"location": "[location()]",
"azfunc_appName": "[steps('azfuncConfig').appName.value]",
"azfunc_storageAccountType": "[steps('azfuncConfig').storageAccounts.type]",
"azfunc_location": "[location()]",
"azfunc_runtime": "[steps('azfuncConfig').runtime.value]"
}
}
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountNamePrefix": {
"type": "string"
},
"storageAccountType": {
"type": "string"
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"azfunc_appName": {
"type": "string",
"metadata": {
"description": "The name of the function app that you wish to create."
}
},
"azfunc_storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS"
],
"metadata": {
"description": "Storage Account type"
}
},
"azfunc_location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"azfunc_runtime": {
"type": "string",
"defaultValue": "node",
"allowedValues": [
"node",
"dotnet",
"java"
],
"metadata": {
"description": "The language worker runtime to load in the function app."
}
}
},
"variables": {
"storageAccountName": "[concat(parameters('storageAccountNamePrefix'), uniqueString(resourceGroup().id))]",
"functionAppName": "[concat(parameters('azfunc_appName'), uniqueString(resourceGroup().id))]",
"functionhostingPlanName": "[parameters('azfunc_appName')]",
"functionapplicationInsightsName": "[parameters('azfunc_appName')]",
"functionstorageAccountName": "[concat(uniquestring(resourceGroup().id), 'azfunctions')]",
"functionstorageAccountid": "[concat(resourceGroup().id,'/providers/','Microsoft.Storage/storageAccounts/', variables('functionstorageAccountName'))]",
"functionWorkerRuntime": "[parameters('azfunc_runtime')]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2016-01-01",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "Storage",
"properties": {}
},
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('functionstorageAccountName')]",
"apiVersion": "2016-12-01",
"location": "[parameters('azfunc_location')]",
"kind": "Storage",
"sku": {
"name": "[parameters('azfunc_storageAccountType')]"
}
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[variables('functionhostingPlanName')]",
"location": "[parameters('azfunc_location')]",
"sku": {
"name": "Y1",
"tier": "Dynamic"
},
"properties": {
"name": "[variables('functionhostingPlanName')]",
"computeMode": "Dynamic"
}
},
{
"apiVersion": "2015-08-01",
"type": "Microsoft.Web/sites",
"name": "[variables('functionAppName')]",
"location": "[parameters('azfunc_location')]",
"kind": "functionapp",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('functionhostingPlanName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('functionstorageAccountName'))]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('functionhostingPlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('functionstorageAccountName'), ';AccountKey=', listKeys(variables('functionstorageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('functionstorageAccountName'), ';AccountKey=', listKeys(variables('functionstorageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(variables('functionAppName'))]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~2"
},
{
"name": "WEBSITE_NODE_DEFAULT_VERSION",
"value": "~10"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('microsoft.insights/components/', variables('functionapplicationInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "[variables('functionWorkerRuntime')]"
}
]
}
}
},
{
"apiVersion": "2018-05-01-preview",
"name": "[variables('functionapplicationInsightsName')]",
"type": "microsoft.insights/components",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('functionapplicationInsightsName'))]": "Resource"
},
"properties": {
"ApplicationId": "[variables('functionapplicationInsightsName')]",
"Request_Source": "IbizaWebAppExtensionCreate"
}
}
],
"outputs": {
"storageEndpoint": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), '2016-01-01').primaryEndpoints.blob]"
}
}
}
{
"$schema": "https://schema.management.azure.com/schemas/viewdefinition/0.0.1-preview/ViewDefinition.json#",
"contentVersion": "0.0.0.1",
"views": [
{
"kind": "Overview",
"properties": {
"header": "Welcome to your Azure Managed Application",
"description": "This managed application is for demo purposes only.",
}
},
{
"kind": "Metrics",
"properties": {
"displayName": "This is my metrics view",
"version": "1.0.0",
"charts": [
{
"displayName": "Sample chart",
"chartType": "Bar",
"metrics": [
{
"name": "Availability",
"aggregationType": "avg",
"resourceType": "Microsoft.Storage/storageAccounts",
"namespace": "Microsoft.Storage/storageAccounts"
},
{
"name": "Availability",
"aggregationType": "avg",
"resourceType": "Microsoft.Web/serverfarms",
"namespace": "Microsoft.Web/serverfarms"
},
{
"name": "Availability",
"aggregationType": "avg",
"resourceType": "Microsoft.Web/sites",
"namespace": "Microsoft.Web/sites"
},
{
"name": "Availability",
"aggregationType": "avg",
"resourceType": "microsoft.insights/components",
"namespace": "microsoft.insights/components"
}
]
}
]
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment