2
votes

I'm trying to setup Application Insights to be attached against Function App, and few Web API's (Azure App Service).

Ideally we want the whole deployment process to be fully automated from VSTS Build and Release so we don't have to setup the resource from Azure Portal.

I've created the ARM template for it and managed to get it to create a new Azure resource of Application Insight, however it's not showing the other settings that I want (i.e. Alert Rules, Billing Type, and Daily Data Cap).

Is setting up Alert Rules currently available via ARM template? if so can someone please help and verify if the ARM template I've got :)?

 {
      "comments": "App Insight Alert Rule",
      "type": "microsoft.insights/alertrules",
      "name": "[parameters('AppInsights.AlertRuleName')]",
      "apiVersion": "2014-04-01",
      "location": "East US",
      "tags": {
        "[concat('hidden-link:/subscriptions/',subscription().subscriptionId,'/resourcegroups/',parameters('ResourceGroupName'),'/providers/microsoft.insights/components/',parameters('AppInsights.Name'))]": "Resource"
      },
      "properties": {
        "name": "[parameters('AppInsights.AlertRuleName')]",
        "description": "",
        "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('AppInsights.Name'))]",
            "metricName": "requestFailed.count"
          },
          "threshold": 1,
          "windowSize": "PT5M"
        },
        "action": {
          "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
          "customEmails": "[array(parameters('AppInsights.AlertSubscriber'))]"
        }
      },
      "dependsOn": [
        "[resourceId('microsoft.insights/components', parameters('AppInsights.Name'))]"
      ]
    },
    {

      "type": "microsoft.insights/components",
      "kind": "web",
      "name": "[parameters('AppInsights.Name')]",
      "apiVersion": "2014-04-01",
      "location": "eastus",
      "tags": {},
      "properties": {
        "ApplicationId": "[parameters('AppInsights.Name')]"
      },
      "dependsOn": []
    },
       {
        "name": "[variables('billingplan')]",
        "type": "microsoft.insights/components/CurrentBillingFeatures",
        "location": "East US",
        "apiVersion": "2015-05-01",
        "dependsOn": [
          "[resourceId('microsoft.insights/components', parameters('AppInsights.Name'))]"
        ],
        "properties": {
          "CurrentBillingFeatures": "[variables('pricePlan')]",
          "DataVolumeCap": {
            "Cap": "[parameters('AppInsights.DailyQuota')]"
          }
        }
      }
  ]
  }

Thanks

Harris

1
can you share the whole template?4c74356b41

1 Answers

0
votes

I've finally found out that the issue was due to me having same Alert Rule names (wasn't aware that alert rules are treated as resource and need to have unique names..).

So I ended up renaming the alert to something different, redeployed the solution and it finally creates the alert rules :).