I'm trying to use an Azure Resource Manager template to create an alert in Application Insights. The problem I'm having is what value I should put for resourceUri. I've tried a few different values, I'm not sure if it's supposed to be the resource I'm monitoring or something else. The documentation is most unhelpful. When I try with the value below it gives me a validation error.
It's also not clear how I actually associate the alert with the component. Is it supposed to be nested as a resource within the component? I have a dependsOn referencing the component but from what I understand that would just ensure the other resource gets created first.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"resources": [
{
"apiVersion": "2014-04-01",
"type": "Microsoft.Insights/components",
"name": "testmetrics",
"location": "Central US"
},
{
"apiVersion": "2014-04-01",
"type": "Microsoft.Insights/alertrules",
"name": "testAlert1",
"dependsOn": [
"[concat('Microsoft.Insights/components/', 'testmetrics')]"
],
"location": "Central US",
"properties": {
"description": "Test description",
"action": {
"customEmails": [ "me#somewhere.com" ]
},
"condition": {
"failedLocationCount": "1",
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"threshold": "0",
"dataSource": {
"metricName": "BackupFailed",
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "/Microsoft.Web/sites/mytestsite"
},
"operator": "GreaterThan",
"windowSize": "1"
}
}
}
]
}
The resourceUrl should refer to the Application Insights service in following format:
"resourceUri": "[concat(resourceGroup().id, '/providers/Microsoft.Insights/components/', 'testmetrics')]"
A great way to figure out how to write these templates correctly (if you can't find a reference in the Github repository for ARM quickstart templates) is to create a resource group in the Azure portal, configure your system and then export to a JSON template (found in the "Setting" blade when you click your resource group).
I just created an example Application Insights resource with an alert and got the one below.
You can see how the dependency is nested and the correct syntax. Also note that location for Central US is provided as "centralus"
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertrules_analertname_name": {
"defaultValue": "analertname",
"type": "String"
},
"components_appinsightname_name": {
"defaultValue": "appinsightname",
"type": "String"
}
},
"variables": {},
"resources": [
{
"comments": "Generalized from resource: '/subscriptions/SOME-SUBSCRIPTIN-GUID/resourceGroups/Default-ApplicationInsights-CentralUS/providers/microsoft.insights/alertrules/analertname'.",
"type": "microsoft.insights/alertrules",
"name": "[parameters('alertrules_analertname_name')]",
"apiVersion": "2014-04-01",
"location": "East US",
"tags": {
"hidden-link:/subscriptions/SOME-SUBSCRIPTIN-GUID/resourcegroups/Default-ApplicationInsights-CentralUS/providers/microsoft.insights/components/appinsightname": "Resource"
},
"properties": {
"name": "[parameters('alertrules_analertname_name')]",
"description": "Some alert",
"isEnabled": true,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[resourceId('microsoft.insights/components', parameters('components_appinsightname_name'))]",
"metricName": "availability.availabilityMetric.value"
},
"threshold": 1,
"windowSize": "PT5M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"customEmails": [
"someemail#example.com"
]
}
},
"dependsOn": [
"[resourceId('microsoft.insights/components', parameters('components_appinsightname_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/SOME-SUBSCRIPTIN-GUID/resourceGroups/Default-ApplicationInsights-CentralUS/providers/microsoft.insights/components/appinsightname'.",
"type": "microsoft.insights/components",
"kind": "web",
"name": "[parameters('components_appinsightname_name')]",
"apiVersion": "2014-04-01",
"location": "centralus",
"tags": {},
"properties": {
"ApplicationId": "[parameters('components_appinsightname_name')]"
},
"dependsOn": []
}
]
}
Hope this helps.
Related
I am trying to link automation account with log analytics and enable update management with below arm template. The resources are getting linked, however not enabling update management. Am I missing something in code
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces','Dev-Loganalyticsworkspace')]",
"[resourceId('Microsoft.Automation/automationAccounts','Dev-Automationaccount')]"
],
"name": "Dev-Loganalyticsworkspace/automation",
"properties": {
"resourceId": "[resourceId('Microsoft.Automation/automationAccounts', 'Dev-Automationaccount')]"
},
"type": "Microsoft.OperationalInsights/workspaces/linkedServices",
"location": "CentralIndia",
"apiVersion": "2020-08-01"
}
]
}
Please find below the updated code. This is executing succesfully, but as mentioned, update management is unable to found
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "Dev-Automationaccount",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"sku": {
"name": "Basic"
}
},
"tags": {
"displayName": "Automation Account.",
"provider": "Kyniac"
},
"comments": "The automation account for LogAnalytics WorkSpace",
"type": "Microsoft.Automation/automationAccounts",
"location": "UK South",
"apiVersion": "2021-06-22"
},
{
"name": "Dev-Loganalyticsworkspace",
"properties": {
"features": {
"searchVersion": 1
},
"sku": {
"retentionInDays": 120,
"resourcePermissions": true,
"heartbeatTableRetention": 90,
"name": "pergb2018"
}
},
"tags": {
"displayName": "LAWorkspace for storing all the logs and metrics.",
"provider": "Kyniac"
},
"comments": "LAWorkspace for storing all the logs and metrics.",
"type": "Microsoft.OperationalInsights/workspaces",
"location": "UK South",
"apiVersion": "2021-12-01-preview"
},
{
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces','Dev-Loganalyticsworkspace')]",
"[resourceId('Microsoft.Automation/automationAccounts','Dev-Automationaccount')]"
],
"name": "Dev-Loganalyticsworkspace/automation",
"properties": {
"resourceId": "[resourceId('Microsoft.Automation/automationAccounts', 'Dev-Automationaccount')]"
},
"type": "Microsoft.OperationalInsights/workspaces/linkedServices",
"location": "UK South",
"apiVersion": "2020-08-01"
},
{
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces', 'Dev-Loganalyticsworkspace')]"
],
"name": "Updates(Dev-Loganalyticsworkspace)",
"properties": {
"workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces', 'Dev-Loganalyticsworkspace')]"
},
"plan": {
"name": "Updates(Dev-Loganalyticsworkspace)",
"product": "OMSGallery/Updates",
"publisher": "Microsoft",
"promotionCode": " "
},
"type": "Microsoft.OperationsManagement/solutions",
"location": "UK South",
"apiVersion": "2015-11-01-preview"
}
]
}
I have tried running your shared arm template in my local visual studio using the PowerShell cmdlet New-AzResourceGroupDeployment Template validation is falling with below error.
New-AzResourceGroupDeployment: 14:51:17 - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The resource 'Microsoft.Automation/automationAccounts/<automationAccount>' is not defined in the template. Please see https://aka.ms/arm-template for usage details.'.
You need to create log analytics solution to enable update management of automation account with log analytics.
I have made the necessary changes to your ARM template that you have shared earlier:
Here is the ARM template:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"automationAccountName": {
"type": "string"
},
"workspaceName": {
"type": "string"
}
},
"functions": [],
"variables": {
"updates": {
"name": "[concat('Updates', '(', parameters('workspaceName'), ')')]",
"galleryName": "Updates"
}
},
"resources": [
{
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2021-12-01-preview",
"name":"[parameters('workspaceName')]",
"location":"westus",
"properties":{
"sku": {
"name": "PerGB2018"
}
},
"resources": [
{
"type":"Microsoft.OperationsManagement/solutions",
"apiVersion":"2015-11-01-preview",
"location":"westus",
"name": "[variables('updates').name]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.OperationsManagement/solutions/', variables('updates').name)]",
"dependsOn": [
"[concat('Microsoft.OperationalInsights/workspaces/', parameters('workspaceName'))]"
],
"properties": {
"workspaceResourceId": "[resourceId('Microsoft.OperationalInsights/workspaces/', parameters('workspaceName'))]"
},
"plan": {
"name": "[variables('updates').name]",
"publisher": "Microsoft",
"promotionCode": "",
"product": "[concat('OMSGallery/', variables('updates').galleryName)]"
}
}
]
},
{
"type": "Microsoft.Automation/automationAccounts",
"apiVersion": "2021-06-22",
"name":"[parameters('automationAccountName')]",
"location":"westus",
"properties":{
"sku": {
"name": "Basic"
}
}
},
{
"type":"Microsoft.OperationalInsights/workspaces/linkedServices",
"apiVersion": "2020-08-01",
"name": "[concat(parameters('workspaceName'),'/','Automation')]",
"dependsOn":[
"[resourceId('Microsoft.OperationalInsights/workspaces',parameters('workspaceName'))]",
"[resourceId('Microsoft.Automation/automationAccounts',parameters('automationAccountName'))]"
],
"location":"westus",
"properties": {
"resourceId":"[resourceId('Microsoft.Automation/automationAccounts/',parameters('automationAccountName'))]"
}
}
],
"outputs": {}
}
I have tested the above ARM template and it is working fine from my end. I would suggest you to test it from your end as well.
I am having a bit of an issue in combining two ARM templates. I want to create an Action Group and then subsequently create an Azure budget alert. I am able to do them individually but I want to create a single Arm template to achieve the task.
Works Fine -Here is the code to create Action Group (Getting the Option to select Resource Group or create one)
{
"type": "microsoft.insights/actionGroups",
"apiVersion": "2019-06-01",
"name": "OG",
"location": "Global",
"properties": {
"groupShortName": "OG",
"enabled": true,
"emailReceivers": [
{
"name": "[concat('Test','OG')]",
"emailAddress": "someemailID#xxx.com",
"useCommonAlertSchema": true
}
]
}
Works Fine - Here is the code to create Budget Alert (Getting the option to select Subscription)
"resources": [
{
"type": "Microsoft.Consumption/budgets",
"apiVersion": "2019-10-01",
"name": "[parameters('budgetName')]",
"properties": {
"timePeriod": {
"startDate": "[parameters('startDate')]",
"endDate": "[parameters('endDate')]"
},
"timeGrain": "[parameters('timeGrain')]",
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"contactEmails": "[parameters('contactEmails')]",
"contactGroups": "[parameters('contactGroups')]"
}
}
}
}
]
And here is the combined code that I have come up with - Not Getting the option to select Resource Group
Problem - While deploying the combined template I am not getting the option to select "Resource Group" I need to have "Resource Group" to create Action Group but not for Budget Alert.
How can I combine the two templates?
Not able to make it work
"resources": [
{
"type": "microsoft.insights/actionGroups",
"apiVersion": "2019-06-01",
"name": "OG",
"location": "Global",
"properties": {
"groupShortName": "OG",
"enabled": true,
"emailReceivers": [
{
"name": "[concat('Test','OG')]",
"emailAddress": "someemailID#xxx.com",
"useCommonAlertSchema": true
}
]
}
},
{
"type": "Microsoft.Consumption/budgets",
"apiVersion": "2019-10-01",
"name": "[parameters('budgetName')]",
"dependsOn": [
"[resourceId('microsoft.insights/actionGroups','OG')]"
],
"properties": {
"timePeriod": {
"startDate": "[parameters('startDate')]",
"endDate": "[parameters('endDate')]"
},
"timeGrain": "[parameters('timeGrain')]",
"amount": "[parameters('amount')]",
"category": "Cost",
"notifications": {
"NotificationForExceededBudget1": {
"enabled": true,
"operator": "GreaterThan",
"threshold": "[parameters('firstThreshold')]",
"contactEmails": "[parameters('contactEmails')]",
"contactGroups": "[resourceId('microsoft.insights/actionGroups','OG')]"
}
}
}
}
]
Please nested the budget in a nest template and target it to subscription level (or management group level)
https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-to-resource-group?tabs=azure-cli
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
your action group resource
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2020-06-01",
"name": "nestedDeployment",
"location": "centralus",
"subscriptionId": "0000000-0000-0000-0000-000000000000",
"properties": {
"mode": "Incremental",
"template": {
your budget resource goes here
}
}
}
],
"outputs": {}
}
How can I tag an Azure resource group using an ARM template and use Azure DevOps task Azure Deployment: Create Or Update Resource Group. I have error No HTTP resource was found that matches the request URI
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"customTags": {
"type": "object",
"defaultValue": {
"Environment Name": "TRdev",
"Environment Type":"Dev",
"Product family":"RT"
}
},
"rgName": {
"type": "string",
"defaultValue": "dev-rg",
"metadata": {
"description": "Name of the resourceGroup to create"
}
},
"serverfarms_environment_sp_sku": {
"defaultValue": "B1",
"allowedValues": [ "B1", "S1", "P1V2", "P2V2", "P3V2"],
"type": "String"
},
"serverfarms_environment_sp_name": {
"defaultValue": "dev-sp",
"type": "String"
},
"sites_environment_api_name": {
"defaultValue": "dev-api",
"type": "String"
},
"sites_environment_ui_name": {
"defaultValue": "dev-ui",
"type": "String"
}
},
"variables": { },
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2018-05-01",
"location": "West US",
"name": "[parameters('rgName')]",
"tags": "[parameters('customTags')]",
"properties": {}
},
{
"apiVersion": "2019-08-01",
"name": "[parameters('rgName')]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[parameters('rgName')]",
"tags": "[parameters('customTags')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.1",
"parameters": {},
"resources": [
{
"apiVersion": "2018-02-01",
"type": "Microsoft.Web/serverfarms",
"kind": "app",
"name": "[parameters('serverfarms_environment_sp_name')]",
"location": "[resourceGroup().location]",
"tags": "[parameters('customTags')]",
"properties": {},
"dependsOn": [],
"sku": {
"name": "[parameters('serverfarms_environment_sp_sku')]"
}
},
{
"apiVersion": "2018-11-01",
"type": "Microsoft.Web/sites",
"kind": "app",
"name": "[parameters('sites_environment_api_name')]",
"location": "[resourceGroup().location]",
"tags": "[parameters('customTags')]",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_environment_sp_name'))]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_environment_sp_name'))]"
]
},
{
"apiVersion": "2018-11-01",
"type": "Microsoft.Web/sites",
"kind": "app",
"name": "[parameters('sites_environment_ui_name')]",
"location": "[resourceGroup().location]",
"tags": "[parameters('customTags')]",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_environment_sp_name'))]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_environment_sp_name'))]"
]
}
]
},
"parameters": {}
}
}
],
"outputs": {
"sites_environment_api_name": {
"type": "string",
"value": "[parameters('sites_environment_api_name')]"
},
"sites_environment_ui_name": {
"type": "string",
"value": "[parameters('sites_environment_ui_name')]"
}
}
}
Error
error No HTTP resource was found that matches the request URI 'https://management.azure.com/subscriptions/subscriptionsID/resourcegroups/resourcegroupsNeme/providers/Microsoft.Resources/resourceGroups/resourcegroupsNeme?api-version=2018-05-01'.
Thanks.
{
"type": "Microsoft.Resources/tags",
"name": "default",
"apiVersion": "2021-04-01",
"properties": {
"tags": "[variables('resourceTags')]"
}
}
You can apply tags to the target resource group by using the "tags" resource. In this case I've used a variable to store my default tags, but you could explicitly define them as well.
Checkout the following for more details:
https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/tag-resources?tabs=json#apply-tags-to-resource-groups-or-subscriptions
What you're trying to achieve is referred to as a subscription level deployment. If you are trying to deploy this through a template via the portal I'm afraid you're out of luck. The deployment UI insists you specify a resource group to deploy in to which invalidates the API path routing when making the call to create your resource group.
To overcome this you'll need to use PowerShell or the Azure CLI.
Another issue with subscription level deployments is that you can't use the resourceGroup() function, so your template will need be adjusted.
Your template should be:
{
"$schema":"https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion":"1.0.0.0",
"parameters":{
"customTags":{
"type":"object",
"defaultValue":{
"Environment Name":"TRdev",
"Environment Type":"Dev",
"Product family":"RT"
}
},
"rgName":{
"type":"string",
"defaultValue":"dev-rg",
"metadata":{
"description":"Name of the resourceGroup to create"
}
},
"serverfarms_environment_sp_sku":{
"defaultValue":"B1",
"allowedValues":[
"B1",
"S1",
"P1V2",
"P2V2",
"P3V2"
],
"type":"String"
},
"serverfarms_environment_sp_name":{
"defaultValue":"dev-sp",
"type":"String"
},
"sites_environment_api_name":{
"defaultValue":"dev-api",
"type":"String"
},
"sites_environment_ui_name":{
"defaultValue":"dev-ui",
"type":"String"
}
},
"variables":{
},
"resources":[
{
"type":"Microsoft.Resources/resourceGroups",
"apiVersion":"2018-05-01",
"location":"West US",
"name":"[parameters('rgName')]",
"tags":"[parameters('customTags')]",
"properties":{
}
},
{
"apiVersion":"2019-08-01",
"name":"[parameters('rgName')]",
"type":"Microsoft.Resources/deployments",
"resourceGroup":"[parameters('rgName')]",
"tags":"[parameters('customTags')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', parameters('rgName'))]"
],
"properties":{
"mode":"Incremental",
"template":{
"$schema":"https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion":"1.0.0.1",
"resources":[
{
"apiVersion":"2018-02-01",
"type":"Microsoft.Web/serverfarms",
"kind":"app",
"name":"[parameters('serverfarms_environment_sp_name')]",
"location":"[resourceGroup().location]",
"tags":"[parameters('customTags')]",
"properties":{
},
"dependsOn":[
],
"sku":{
"name":"[parameters('serverfarms_environment_sp_sku')]"
}
},
{
"apiVersion":"2018-11-01",
"type":"Microsoft.Web/sites",
"kind":"app",
"name":"[parameters('sites_environment_api_name')]",
"location":"[resourceGroup().location]",
"tags":"[parameters('customTags')]",
"properties":{
"serverFarmId":"[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_environment_sp_name'))]"
},
"dependsOn":[
"[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_environment_sp_name'))]"
]
},
{
"apiVersion":"2018-11-01",
"type":"Microsoft.Web/sites",
"kind":"app",
"name":"[parameters('sites_environment_ui_name')]",
"location":"[resourceGroup().location]",
"tags":"[parameters('customTags')]",
"properties":{
"serverFarmId":"[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_environment_sp_name'))]"
},
"dependsOn":[
"[resourceId('Microsoft.Web/serverfarms', parameters('serverfarms_environment_sp_name'))]"
]
}
]
},
}
}
],
"outputs":{
"sites_environment_api_name":{
"type":"string",
"value":"[parameters('sites_environment_api_name')]"
},
"sites_environment_ui_name":{
"type":"string",
"value":"[parameters('sites_environment_ui_name')]"
}
}
}
You can save this file to your local machine and deploy as follows.
PowerShell:
New-AzDeployment -TemplateFile '<path-to-template>' -Location 'West US'
Azure CLI:
az deployment create --template-file "<path-to-template>" --location "US West"
You will see a warning about upcoming breaking changes. Microsoft are introducing a mandatory parameter ScopeType to the PowerShell, and scope-type to the CLI with four possible values - ResourceGroup, Subscription, ManagementGroup and Tenant. In this instance, you would set ScopeType to Subscription, but you can see where Microsoft are going with the others.
I expect the portal template deployment UI will be updated soon.
Alternatively the ARM template can remain as is and have an additional step after to run just some simple powershell like:
Set-AzResourceGroup -Name "YOURRESOURCEGROUPNAME" -Tag #{Department="IT"}
This would allow you to maintain the current CI/CD structure.
More information on using Powershell to update the Resource Group
I have a site with custom hostnames configured with hostnameBindings in the ARM template. This deploys fine.
I have also the SSL certificate created and verified from Azure, with the corresponding thumbprint.
In the Azure site I am also able to bind the certificate to the app service.
But when I use the ARM template to assign the SSL from the template in the hostnameBindings it gives an error that the certificate was not found...
I don't understand what goes wrong...
My guesses:
the certificate is in a different resource group so it cannot be
found, but in the template settings I cannot set the group.
in the Azure website before I can use the SSL I have to import, so maybe I am missing this step in the ARM template?
using wrong thumbprint?
In the hostnameBindings I am defining only the thumbprint and the sslState
Any idea which step I am missing?
thank you
UPDATE
My parameter json file:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.5.0.8",
"parameters": {
"baseResourceName": {
"value": "base-name"
},
"environments": {
"value": [
"preview"
]
},
"hostNames": {
"value": [
{
"name": "myhostname.example.com",
"sslState": "SniEnabled",
"thumbprint": "9897LKJL88KHKJH8888KLJLJLJLKJLJLKL4545"
},
{
"name": "myhostname2.example.com"
}
]
},
"ipSecurityRestrictions": {
"value": []
}
}
}
My template json file:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.5.0.8",
"parameters": {
"hostName": {
"defaultValue": [],
"type": "array",
"metadata": {
"description": "The custom hostnames of sites"
}
}
},
"variables": {
"standardPlanMaxAdditionalSlots": 4,
"appName": "[concat(parameters('baseResourceName'), '-private')]",
"appServicePlanName": "[concat(parameters('baseResourceName'), '-appServicePlan')]",
"appInsightName": "[concat(parameters('baseResourceName'), '-appInsight')]",
"ipSecurityRestrictions": "[parameters('ipSecurityRestrictions')]"
},
"resources": [
{
"type": "Microsoft.Web/serverfarms",
"comments": "AppPlan for app.",
"sku": {
"name": "[if(lessOrEquals(length(parameters('environments')), variables('standardPlanMaxAdditionalSlots')), 'S1', 'P1')]"
},
"tags": {
"displayName": "AppServicePlan-Private"
},
"name": "[variables('appServicePlanName')]",
"kind": "app",
"apiVersion": "2016-09-01",
"location": "[resourceGroup().location]",
"properties": {},
"dependsOn": []
},
{
"type": "Microsoft.Web/sites",
"comments": "This is the private web app.",
"kind": "app",
"apiVersion": "2016-03-01",
"name": "[variables('appName')]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "WebApp"
},
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"siteConfig": {
"appSettings": [],
"phpVersion": "",
"ipSecurityRestrictions": "[variables('ipSecurityRestrictions')]",
"http20Enabled": true,
"minTlsVersion": "1.2"
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"[resourceId('microsoft.insights/components/', variables('appInsightName'))]"
]
},
{
"type": "Microsoft.Web/sites/hostnameBindings",
"name": "[concat(variables('appName'), '/', parameters('hostName')[copyIndex()].Name)]",
"apiVersion": "2016-03-01",
"location": "[resourceGroup().location]",
"properties": "[parameters('hostName')[copyIndex()]]",
"condition": "[greater(length(parameters('hostName')), 0)]",
"copy": {
"name": "hostnameCopy",
"count": "[length(parameters('hostName'))]",
"mode": "Serial"
},
"dependsOn": [
"[concat('Microsoft.Web/sites/',variables('appName'))]"
]
}
]
}
completely unrelated, did you test your condition greater(..., 0) with zero length array? pretty sure it will blow up.
on the subject. i think you can maybe make it work if you link your certificate resource to the app service plan. so this is an operation that is performed on the certificate resource. this is totally possible if you use keyvault to store the certificate
{
"apiVersion": "2016-03-01",
"name": "[variables('certificateName')]",
"location": "[resourceGroup().location]",
"type": "Microsoft.Web/certificates",
"dependsOn": [
"[parameters('appServicePlan')]"
],
"properties": {
"keyVaultId": "kvResourceId",
"keyVaultSecretName": "secretName",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlan'))]"
}
}
I use below JSON to create AI alert, which works fine. However when I try to add add multiple alerts in this JSON file, it creates few alerts, sometimes one and other times two or three and finally returns provisioning state as Failed. It never creates all the alerts in the JSON (six).
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"AlertName": {
"type": "string"
},
"Location": {
"type": "string",
"defaultValue": "East US"
},
"ResourceGroup": {
"type": "string"
},
"ResourceName": {
"type": "string"
}
},
"resources": [{
"apiVersion": "2014-04-01",
"name": "[parameters('AlertName')]",
"type": "microsoft.insights/alertrules",
"location": "[parameters('Location')]",
"tags": {
"displayName": "AppInsightsAlert"
},
"properties": {
"name": "[concat('AppInsightsAlert ', parameters('AlertName'))]",
"description": "[concat('App Insights Alert ', parameters('AlertName'))]",
"isEnabled": true,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri": "[concat('/subscriptions/<subscription id>/resourcegroups/', parameters('ResourceGroup'), '/providers/microsoft.insights/components/', parameters('ResourceName'))]",
"metricName": "view.count"
},
"threshold": 1,
"windowSize": "PT5M"
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners": true,
"customEmails": []
}
}
}]
}
Are you using PowerShell for deployment - if so, add the -debug switch to the New-AzureResourceGroup* command and sift through the output. The raw error from the platform is in there and it's usually pretty good. If that doesn't help, can you post the entire json template for the deployments that are failing?