Skip to content

Instantly share code, notes, and snippets.

@martijndierckx
Created February 11, 2021 12:14
Show Gist options
  • Save martijndierckx/461ab4e64fecd3351d42c731af265197 to your computer and use it in GitHub Desktop.
Save martijndierckx/461ab4e64fecd3351d42c731af265197 to your computer and use it in GitHub Desktop.
Keyvault acmebot template with custom names + existing components
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"type": "string",
"metadata": {
"description": "Name of the new Functions service"
}
},
"appInsightsName": {
"type": "string",
"metadata": {
"description": "Name of the new Insights"
}
},
"appPlanName": {
"type": "string",
"metadata": {
"description": "Name of the existing app plan"
}
},
"storageName": {
"type": "string",
"metadata": {
"description": "Name of the existing storage"
}
},
"mailAddress": {
"type": "string",
"metadata": {
"description": "Email address for ACME account."
}
},
"acmeEndpoint": {
"type": "string",
"allowedValues": [
"https://acme-v02.api.letsencrypt.org/",
"https://api.buypass.com/acme/"
],
"defaultValue": "https://acme-v02.api.letsencrypt.org/",
"metadata": {
"description": "Certification authority ACME Endpoint."
}
},
"keyVaultBaseUrl": {
"type": "string",
"metadata": {
"description": "Enter the base URL of an existing Key Vault. (ex. https://example.vault.azure.net)"
}
}
},
"variables": {
"functionAppName": "[parameters('appName')]",
"appServicePlanName": "[parameters('appPlanName')]",
"appInsightsName": "[parameters('appInsightsName')]",
"storageAccountName": "[parameters('storageName')]",
"storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"mailAddress": "[parameters('mailAddress')]",
"acmeEndpoint": "[parameters('acmeEndpoint')]",
"vaultBaseUrl": "[parameters('keyVaultBaseUrl')]",
"appInsightsEndpoints": {
"AzureCloud": "applicationinsights.azure.com",
"AzureChinaCloud": "applicationinsights.azure.cn",
"AzureUSGovernment": "applicationinsights.us"
}
},
"resources": [
{
"type": "Microsoft.Insights/components",
"name": "[variables('appInsightsName')]",
"apiVersion": "2015-05-01",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('functionAppName'))]": "Resource"
},
"properties": {
"Application_Type": "web",
"applicationId": "[variables('appInsightsName')]"
}
},
{
"type": "Microsoft.Web/sites",
"name": "[variables('functionAppName')]",
"apiVersion": "2020-06-01",
"location": "[resourceGroup().location]",
"kind": "functionapp",
"identity": {
"type": "SystemAssigned"
},
"dependsOn": [
"[resourceId('Microsoft.Insights/components', variables('appInsightsName'))]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "[concat('InstrumentationKey=', reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2015-05-01').InstrumentationKey, ';EndpointSuffix=', variables('appInsightsEndpoints')[environment().name])]"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), '2018-11-01').keys[0].value, ';EndpointSuffix=', environment().suffixes.storage)]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'), '2018-11-01').keys[0].value, ';EndpointSuffix=', environment().suffixes.storage)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(variables('functionAppName'))]"
},
{
"name": "WEBSITE_RUN_FROM_PACKAGE",
"value": "https://shibayan.blob.core.windows.net/azure-keyvault-letsencrypt/v3/latest.zip"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~3"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "dotnet"
},
{
"name": "Acmebot:Contacts",
"value": "[variables('mailAddress')]"
},
{
"name": "Acmebot:Endpoint",
"value": "[variables('acmeEndpoint')]"
},
{
"name": "Acmebot:VaultBaseUrl",
"value": "[variables('vaultBaseUrl')]"
},
{
"name": "Acmebot:Environment",
"value": "[environment().name]"
}
],
"clientAffinityEnabled": false
},
"ftpsState": "Disabled",
"httpsOnly": true
},
"resources": [
{
"apiVersion": "2020-06-01",
"name": "metadata",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('functionAppName'))]"
],
"properties": {
"synctriggersstatus": "[listsyncfunctiontriggerstatus(resourceId('Microsoft.Web/sites', variables('functionAppName')), '2020-06-01').status]"
}
}
]
}
],
"outputs": {
"functionAppName": {
"type": "string",
"value": "[variables('functionAppName')]"
},
"identity": {
"type": "object",
"value": "[reference(resourceId('Microsoft.Web/sites', variables('functionAppName')), '2020-06-01', 'Full').identity]"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment