Reputation: 11
while running the workflow file in github to deploy a functionapp I'm getting the below error which is failing with error.
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subscriptionId": {
"type": "string"
},
"resourceGroup": {
"type": "string"
},
"rgTags": {
"type": "object"
},
"funcAppName": {
"type": "string"
},
"location": {
"type": "string"
},
"hostingPlanName": {
"type": "string"
},
"funcAppSku": {
"type": "string"
},
"funcAppSkuCode": {
"type": "string"
},
"appInsightsName": {
"type": "string"
},
"storageAccountName": {
"type": "string"
},
"vnetName": {
"type": "string"
},
"laWorkspaceName": {
"type": "string"
},
"laWorkspaceRGName": {
"type": "string"
},
"tagEnvironment": {
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.Resources/tags",
"name": "default",
"apiVersion": "2021-04-01",
"properties": {
"tags": "[parameters('rgTags')]"
}
},
{
"type": "Microsoft.Web/sites",
"name": "[parameters('funcAppName')]",
"apiVersion": "2018-11-01",
"kind": "functionapp",
"location": "[parameters('location')]",
"tags": {
"Environment": "[parameters('tagEnvironment')]"
},
"dependsOn": [
"[concat('microsoft.insights/components/', parameters('appInsightsName'))]",
"[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"
],
"properties": {
"name": "[parameters('funcAppName')]",
"siteConfig": {
"appSettings": [
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~4"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "powershell"
},
{
"name": "WEBSITE_LOAD_CERTIFICATES",
"value": "*"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(concat('microsoft.insights/components/', parameters('appInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "[reference(concat('microsoft.insights/components/', parameters('appInsightsName')), '2015-05-01').ConnectionString]"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value,';EndpointSuffix=','core.windows.net')]"
},
{
"name": "FUNCTIONS_WORKER_PROCESS_COUNT",
"value": "2"
},
{
"name": "PSWorkerInProcConcurrencyUpperBound",
"value": "2"
}
],
"use32BitWorkerProcess": false,
"alwaysOn": true,
"powerShellVersion": "~7",
"http20Enabled": true,
"minTlsVersion": "1.2",
"ftpsState": "FtpsOnly"
},
"serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('resourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
"clientAffinityEnabled": false
},
"resources": [
{
"apiVersion": "2018-11-01",
"name": "virtualNetwork",
"type": "config",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('funcAppName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"
],
"properties": {
"subnetResourceId": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), 'default')]",
"swiftSupported": true
}
}
]
},
{
"apiVersion": "2018-11-01",
"name": "[parameters('hostingPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[parameters('location')]",
"kind": "",
"tags": {
"Environment": "[parameters('tagEnvironment')]"
},
"dependsOn": [],
"properties": {
"name": "[parameters('hostingPlanName')]",
"workerSize": "0",
"workerSizeId": "0",
"numberOfWorkers": "1"
},
"sku": {
"Tier": "[parameters('funcAppSku')]",
"Name": "[parameters('funcAppSkuCode')]"
}
},
{
"apiVersion": "2020-02-02",
"name": "[parameters('appInsightsName')]",
"type": "microsoft.insights/components",
"location": "[parameters('location')]",
"tags": {
"Environment": "[parameters('tagEnvironment')]"
},
"dependsOn": [],
"properties": {
"ApplicationId": "[parameters('funcAppName')]",
"Request_Source": "IbizaWebAppExtensionCreate",
"Flow_Type": "Redfield",
"Application_Type": "web",
"WorkspaceResourceId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourceGroups/', parameters('laWorkspaceRGName'), '/providers/Microsoft.OperationalInsights/workspaces/', parameters('lAWorkspaceName'))]",
"IngestionMode": "LogAnalytics",
"publicNetworkAccessForIngestion": "Enabled",
"publicNetworkAccessForQuery": "Enabled"
}
},
{
"apiVersion": "2019-06-01",
"type": "Microsoft.Storage/storageAccounts",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"tags": {
"Environment": "[parameters('tagEnvironment')]"
},
"sku": {
"name": "Standard_LRS"
},
"properties": {
"supportsHttpsTrafficOnly": true,
"minimumTlsVersion": "TLS1_2"
}
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-11-01",
"name": "[parameters('vnetName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "default",
"properties": {
"addressPrefix": "10.0.0.0/24",
"serviceEndpoints": [
{
"service": "Microsoft.Storage.Global",
"locations": [
"*"
]
}
],
"delegations": [
{
"name": "delegation",
"properties": {
"serviceName": "Microsoft.Web/serverfarms"
}
}
],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
],
"virtualNetworkPeerings": [],
"enableDdosProtection": false
},
"tags": {
"Environment": "[parameters('tagEnvironment')]"
}
}
]
}
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subscriptionId": {
"value": ""
},
"resourceGroup": {
"value": ""
},
"rgTags": {
"value": null
},
"funcAppName": {
"value": ""
},
"location": {
"value": ""
},
"hostingPlanName": {
"value": ""
},
"funcAppSku": {
"value": ""
},
"funcAppSkuCode": {
"value": ""
},
"appInsightsName": {
"value": ""
},
"storageAccountName": {
"value": ""
},
"vnetName": {
"value": ""
},
"laWorkspaceName": {
"value": ""
},
"laWorkspaceRGName": {
"value": ""
},
"tagEnvironment": {
"value": ""
}
}
}
Error:
##[debug]Select-AzSubscription -Subscription dc86c13b-36f0-4b2f-a42d-1bd68ebdaaf7
##[debug]New-AzResourceGroupDeployment -ResourceGroupName az-xxx-xxx-rg-businessfuncappxayb ##[debug]-TemplateFile arm-templates/business-subscription-afna/template.json
##[debug]-TemplateParameterFile arm-templates/business-subscription-afna/parameters.json
##[debug]script file to run: D:\a_temp\73d8fc60-7cad-4983-8b66-2d762ae62181.ps1
"C:\Program Files\PowerShell\7\pwsh.exe" -NoLogo -NoProfile -NonInteractive -Command D:\a_temp\73d8fc60-7cad-4983-8b66-2d762ae62181.ps1
New-AzResourceGroupDeployment: D:\a_temp\73d8fc60-7cad-4983-8b66-2d762ae62181.ps1:3 Line | 3 | New-AzResourceGroupDeployment -ResourceGroupName az-dna-113-rg-busine … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 11:44:45 AM - Error: Code=InvalidTemplateDeployment; Message=The template deployment 'template' is not valid | according to the validation procedure. The tracking id is 'xxxxxxx-f32f-459c-9487-xxxxxxxx'. See inner errors for details. Error: Error: The process 'C:\Program Files\PowerShell\7\pwsh.exe' failed with exit code 1
Upvotes: 0
Views: 1131
Reputation: 8008
Your code looks good to achieve your requirement. Verify below points to avoid conflicts.
There might be an error occurred with New-AzResourceGroupDeployment
PowerShell command. Try using
az deployment group create
CLI command in the below way for efficient ARM deployments.
az deployment group create --resource-group xxx --template-file github.json
As @jdweng suggested, try validating the Json
template with ARM tool kits available in the online or any.
Recheck the resource dependences and parameter configurations inside the code to avoid these kind of issues.
Sometimes redeploying the template with a new environment will make the code works as expected.
Saying that, I have tried similar code in my environment and was able to deploy it successfully as shown.
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subscriptionId": {
"type": "string",
"defaultValue":"xxx"
},
"resourceGroup": {
"type": "string",
"defaultValue": "xxx"
},
"sku": {
"type": "string",
"defaultValue": "PerGB2018",
"allowedValues": [
"CapacityReservation",
"Free",
"LACluster",
"PerGB2018",
"PerNode",
"Premium",
"Standalone",
"Standard"
],
"metadata": {
"description": "Specify the pricing tier."
}
},
"rgTags": {
"type": "object",
"defaultValue": {
"createdby": "jahnavi",
"Environment": "Production"
}
},
"funcAppName": {
"type": "string",
"defaultValue": "newapjm"
},
"location": {
"type": "string",
"defaultValue": "eastus"
},
"hostingPlanName": {
"type": "string",
"defaultValue": "myplanja"
},
"funcAppSku": {
"type": "string",
"defaultValue": "Standard"
},
"funcAppSkuCode": {
"type": "string",
"defaultValue":"S1"
},
"appInsightsName": {
"type": "string",
"defaultValue": "myinsigjah"
},
"storageAccountName": {
"type": "string",
"defaultValue": "newjstr"
},
"vnetName": {
"type": "string",
"defaultValue": "latestvnj"
},
"laWorkspaceName": {
"type": "string",
"defaultValue": "kurklay"
},
"laWorkspaceRGName": {
"type": "string",
"defaultValue": "v-jahnavi-Mindtree"
},
"tagEnvironment": {
"type": "string",
"defaultValue": "production"
}
},
"resources": [
{
"type": "Microsoft.Resources/tags",
"name": "default",
"apiVersion": "2021-04-01",
"properties": {
"tags": "[parameters('rgTags')]"
}
},
{
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2021-12-01-preview",
"name": "[parameters('laWorkspaceName')]",
"location": "[parameters('location')]",
"properties": {
"sku": {
"name": "[parameters('sku')]"
}
}
},
{
"type": "Microsoft.Web/sites",
"name": "[parameters('funcAppName')]",
"apiVersion": "2018-11-01",
"kind": "functionapp",
"location": "[parameters('location')]",
"tags": {
"Environment": "[parameters('tagEnvironment')]"
},
"dependsOn": [
"[concat('microsoft.insights/components/', parameters('appInsightsName'))]",
"[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"
],
"properties": {
"name": "[parameters('funcAppName')]",
"siteConfig": {
"appSettings": [
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~4"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "powershell"
},
{
"name": "WEBSITE_LOAD_CERTIFICATES",
"value": "*"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(concat('microsoft.insights/components/', parameters('appInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "[reference(concat('microsoft.insights/components/', parameters('appInsightsName')), '2015-05-01').ConnectionString]"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value,';EndpointSuffix=','core.windows.net')]"
},
{
"name": "FUNCTIONS_WORKER_PROCESS_COUNT",
"value": "2"
},
{
"name": "PSWorkerInProcConcurrencyUpperBound",
"value": "2"
}
],
"use32BitWorkerProcess": false,
"alwaysOn": true,
"powerShellVersion": "~7",
"http20Enabled": true,
"minTlsVersion": "1.2",
"ftpsState": "FtpsOnly"
},
"serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('resourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
"clientAffinityEnabled": false
},
"resources": [
{
"apiVersion": "2018-11-01",
"name": "virtualNetwork",
"type": "config",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('funcAppName'))]",
"[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"
],
"properties": {
"subnetResourceId": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), 'default')]",
"swiftSupported": true
}
}
]
},
{
"apiVersion": "2018-11-01",
"name": "[parameters('hostingPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[parameters('location')]",
"kind": "",
"tags": {
"Environment": "[parameters('tagEnvironment')]"
},
"dependsOn": [],
"properties": {
"name": "[parameters('hostingPlanName')]",
"workerSize": "0",
"workerSizeId": "0",
"numberOfWorkers": "1"
},
"sku": {
"Tier": "[parameters('funcAppSku')]",
"Name": "[parameters('funcAppSkuCode')]"
}
},
{
"apiVersion": "2020-02-02",
"name": "[parameters('appInsightsName')]",
"type": "microsoft.insights/components",
"location": "[parameters('location')]",
"tags": {
"Environment": "[parameters('tagEnvironment')]"
},
"dependsOn": [],
"properties": {
"ApplicationId": "[parameters('funcAppName')]",
"Request_Source": "IbizaWebAppExtensionCreate",
"Flow_Type": "Redfield",
"Application_Type": "web",
"WorkspaceResourceId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourceGroups/', parameters('laWorkspaceRGName'), '/providers/Microsoft.OperationalInsights/workspaces/', parameters('lAWorkspaceName'))]",
"IngestionMode": "LogAnalytics",
"publicNetworkAccessForIngestion": "Enabled",
"publicNetworkAccessForQuery": "Enabled"
}
},
{
"apiVersion": "2019-06-01",
"type": "Microsoft.Storage/storageAccounts",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"tags": {
"Environment": "[parameters('tagEnvironment')]"
},
"sku": {
"name": "Standard_LRS"
},
"properties": {
"supportsHttpsTrafficOnly": true,
"minimumTlsVersion": "TLS1_2"
}
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-11-01",
"name": "[parameters('vnetName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "default",
"properties": {
"addressPrefix": "10.0.0.0/24",
"serviceEndpoints": [
{
"service": "Microsoft.Storage.Global",
"locations": [
"*"
]
}
],
"delegations": [
{
"name": "delegation",
"properties": {
"serviceName": "Microsoft.Web/serverfarms"
}
}
],
"privateEndpointNetworkPolicies": "Enabled",
"privateLinkServiceNetworkPolicies": "Enabled"
}
}
],
"virtualNetworkPeerings": [],
"enableDdosProtection": false
},
"tags": {
"Environment": "[parameters('tagEnvironment')]"
}
}
]
}
Deployment succeeded:
Upvotes: 0