I tried to deploy function App to azure portal using ARM template it includes a HTTP trigger .But when I am deploying to azure portal the function app is deploying successfully but the HTTP trigger was not deployed into the function app
As mentioned in the above tried to deploy function App but when I am deploying to azure portal the function app is deploying successfully but the HTTP trigger was not deployed into the function app.
I have deployed a function app with Http Trigger using arm template follow the below steps
Open azure portal and navigate to Custom deployment and use the below template.
Thanks @bmoore-msft
for the template.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.5.6.12127",
"templateHash": "4232340575241655894"
}
},
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Specifies region of all resources."
}
},
"appNameSuffix": {
"type": "string",
"defaultValue": "[uniqueString(resourceGroup().id)]",
"metadata": {
"description": "name for function app ,keyvalut and storage account"
}
},
"keyVaultSku": {
"type": "string",
"defaultValue": "Standard",
"metadata": {
"description": "Key Vault SKU name."
}
},
"storageSku": {
"type": "string",
"defaultValue": "Standard_LRS",
"metadata": {
"description": "Storage account SKU name."
}
}
},
"variables": {
"functionAppName": "[format('fn-{0}', parameters('appNameSuffix'))]",
"appServicePlanName": "FunctionPlan",
"appInsightsName": "AppInsights",
"storageAccountName": "[format('fnstor{0}', replace(parameters('appNameSuffix'), '-', ''))]",
"functionNameComputed": "MyHttpTriggere",
"functionRuntime": "dotnet",
"keyVaultName": "[format('kv{0}', replace(parameters('appNameSuffix'), '-', ''))]",
"functionAppKeySecretName": "FunctionAppHostKey"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-04-01",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageSku')]"
},
"kind": "StorageV2",
"properties": {
"supportsHttpsTrafficOnly": true,
"encryption": {
"services": {
"file": {
"keyType": "Account",
"enabled": true
},
"blob": {
"keyType": "Account",
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot"
}
},
{
"type": "Microsoft.Insights/components",
"apiVersion": "2020-02-02",
"name": "[variables('appInsightsName')]",
"location": "[parameters('location')]",
"kind": "web",
"properties": {
"Application_Type": "web",
"publicNetworkAccessForIngestion": "Enabled",
"publicNetworkAccessForQuery": "Enabled"
}
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2020-12-01",
"name": "[variables('appServicePlanName')]",
"location": "[parameters('location')]",
"kind": "functionapp",
"sku": {
"name": "Y1"
},
"properties": {}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2020-12-01",
"name": "[variables('functionAppName')]",
"location": "[parameters('location')]",
"kind": "functionapp",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "AzureWebJobsStorage",
"value": "[format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix={1};AccountKey={2}', variables('storageAccountName'), environment().suffixes.storage, listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2021-04-01').keys[0].value)]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix={1};AccountKey={2}', variables('storageAccountName'), environment().suffixes.storage, listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2021-04-01').keys[0].value)]"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName'))).InstrumentationKey]"
},
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "[format('InstrumentationKey={0}', reference(resourceId('Microsoft.Insights/components', variables('appInsightsName'))).InstrumentationKey)]"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "[variables('functionRuntime')]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~3"
}
]
},
"httpsOnly": true
},
"dependsOn": [
"[resourceId('Microsoft.Insights/components', variables('appInsightsName'))]",
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"type": "Microsoft.Web/sites/functions",
"apiVersion": "2020-12-01",
"name": "[format('{0}/{1}', variables('functionAppName'), variables('functionNameComputed'))]",
"properties": {
"config": {
"disabled": false,
"bindings": [
{
"name": "req",
"type": "httpTrigger",
"direction": "in",
"authLevel": "function",
"methods": [
"get"
]
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
]
},
"files": {
"run.csx": "#r \"Newtonsoft.Json\"\n\nusing System.Net;\nusing Microsoft.AspNetCore.Mvc;\nusing Microsoft.Extensions.Primitives;\nusing Newtonsoft.Json;\n\npublic static async Task<IActionResult> Run(HttpRequest req, ILogger log)\n{\n log.LogInformation(\"C# HTTP trigger function processed a request.\");\n\n string name = req.Query[\"name\"];\n\n string requestBody = await new StreamReader(req.Body).ReadToEndAsync();\n dynamic data = JsonConvert.DeserializeObject(requestBody);\n name = name ?? data?.name;\n\n string responseMessage = string.IsNullOrEmpty(name)\n ? \"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.\"\n : $\"Hello, {name}. This HTTP triggered function executed successfully.\";\n\n return new OkObjectResult(responseMessage);\n}"
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('functionAppName'))]"
]
},
{
"type": "Microsoft.KeyVault/vaults",
"apiVersion": "2019-09-01",
"name": "[variables('keyVaultName')]",
"location": "[parameters('location')]",
"properties": {
"tenantId": "[subscription().tenantId]",
"sku": {
"family": "A",
"name": "[parameters('keyVaultSku')]"
},
"accessPolicies": []
}
},
{
"type": "Microsoft.KeyVault/vaults/secrets",
"apiVersion": "2019-09-01",
"name": "[format('{0}/{1}', variables('keyVaultName'), variables('functionAppKeySecretName'))]",
"properties": {
"value": "[listKeys(format('{0}/host/default', resourceId('Microsoft.Web/sites', variables('functionAppName'))), '2020-12-01').functionKeys.default]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('functionAppName'))]",
"[resourceId('Microsoft.KeyVault/vaults', variables('keyVaultName'))]"
]
}
],
"outputs": {
"functionAppHostName": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Web/sites', variables('functionAppName'))).defaultHostName]"
},
"functionName": {
"type": "string",
"value": "[variables('functionNameComputed')]"
}
}
}