I'm trying to find what is wrong in my Template Deployment for Azure Alert. I want to Send Email and triggered a WebHook in Azure WebJobs with Basic Authentification.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {
},
"resources": [
{
"type": "Microsoft.Insights/alertRules",
"name": "tesTalert",
"location": "westeurope",
"apiVersion": "2014-04-01",
"properties": {
"name": "test",
"isEnabled": true,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource",
"operationName": "RunFinished",
"status": "Failed",
"subStatus": "FailedExecution"
}
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction",
"serviceUri": "https://$myUserName:MyPassWord#MyWebsite.scm.azurewebsites.net/api/triggeredwebjobs/WebJobName/run",
"properties": {}
}
}
}
]
}
i have also try with this template with email and it's working but not for the webhook. Maybe the problem is from the api version , so i try different version. Nothing happend.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"resources": [
{
"type": "microsoft.insights/alertrules",
"name": "ADFAlertsSlice",
"apiVersion": "2015-01-01",
"location": "westeurope",
"properties": {
"name": "ADFAlertsSlice",
"description": "One or more of the data slices for the Azure Data Factory has failed processing.",
"isEnabled": true,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource",
"operationName": "RunFinished",
"status": "Failed",
"subStatus": "FailedExecution"
}
},
"actions": [
{
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleWebhookAction",
"serviceUri": "https://$myUserName:MyPassWord#MyWebsite.scm.azurewebsites.net/api/triggeredwebjobs/WebJobName/run",
"properties": {}
},
{
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"customEmails": [
"MyEmail#email.com"
]
}
]
}
}
]
}
I can't find what is wrong. thanks for your help.
According to Microsoft docs, webhooks from metric alert rules can only use token authentication.
Authenticating the webhook
The webhook can authenticate using token-based authorization. The webhook URI is saved with a token ID, eg.
https://mysamplealert/webcallback?tokenid=sometokenid&someparameter=somevalue
https://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/insights-webhooks-alerts
And if you scroll down to the comments other ahve the same issue as you do, they even started a feature request with MS.
https://feedback.azure.com/forums/602299-azure-alert-management/suggestions/19711606-enable-user-password-authentication-to-webhooks
Related
I have an ARM template deploying Application Insights to Azure.
From there I need to get "Application Id"
"Application Id of the Application Insights resource that is monitoring the service that you are deploying in the release flow. Find it in the API access blade"
Add an output like this to your template:
"outputs": {
"AppInsightAppId": {
"type": "String",
"value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2014-04-01').AppId]"
}
}
For example:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appInsightsNamePrefix": {
"defaultValue": "",
"type": "String"
}
},
"variables": {
"appInsightsName": "[concat(parameters('appInsightsNamePrefix'), uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Insights/components",
"apiVersion": "2014-04-01",
"name": "[variables('appInsightsName')]",
"location": "[resourceGroup().location]",
"kind": "web",
"properties": {
"ApplicationId": "[variables('appInsightsName')]"
}
}
],
"outputs": {
"AppInsightAppId": {
"type": "String",
"value": "[reference(resourceId('Microsoft.Insights/components', variables('appInsightsName')), '2014-04-01').AppId]"
}
}
}
is there any way to receive a mail (some kind of alert) when someone creates a new Pipeline in a Specific Data Factory?
Something like "user XYZ created a new Pipeline"
Thanks for your inputs,
Marcelo
To specify an alert definition, you create a JSON file describing the operations that you want to be alerted on.
Following example creates an alert for Run Completion.
Below JSON will help you to create similar for update alert.
{
"contentVersion": "1.0.0.0",
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"parameters": {},
"resources": [
{
"name": "ADFAlertsSlice",
"type": "microsoft.insights/alertrules",
"apiVersion": "2014-04-01",
"location": "East US",
"properties": {
"name": "ADFAlertsSlice",
"description": "One or more of the data slices for the Azure Data Factory has failed processing.",
"isEnabled": true,
"condition": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition",
"dataSource": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource",
"operationName": "RunFinished",
"status": "Failed",
"subStatus": "FailedExecution"
}
},
"action": {
"odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"customEmails": [
"#contoso.com"
]
}
}
}
I am creating an EventGrid API Connection using an ARM Template. It gets created successfully, however, i still have to authenticate it by hand via Azure Portal.
Here is my ARM Template:
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('azureEventGridConnectionAPIName')]",
"location": "[resourceGroup().location]",
"properties": {
"api": {
"id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/', 'azureeventgrid')]"
},
"displayName": "[parameters('azureEventGridConnectionAPIName')]"
},
"dependsOn": []
}
]
Am i missing something in the template that is responsible for authenticating the Connection right away?
Is there a way to authenticate that connection using for example Azure PowerShell so i can automate that process?
Am i missing something in the template that is responsible for authenticating the Connection right away?
Yes, we could create a service principal authentication during deploy. Following is the demo code.
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('azureEventGridConnectionAPIName')]",
"location": "[resourceGroup().location]",
"properties": {
"api": {
"id": "[concat('/subscriptions/subscriptionId', '/providers/Microsoft.Web/locations/', 'eastasia', '/managedApis/', 'azureeventgrid')]"
},
"parameterValues": {
"token:clientId": "[parameters('clientId')]",
"token:clientSecret": "[parameters('clientSecret')]",
"token:TenantId": "[parameters('TenantId')]",
"token:grantType": "[parameters('grantType')]"
},
"displayName": "[parameters('azureEventGridConnectionAPIName')]"
},
"dependsOn": []
}
]
Parameters.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"azureEventGridConnectionAPIName": {
"value": "azureEventGridConnectionAPIName"
},
"clientId": {
"value": "clientId"
},
"clientSecret": {
"value": "secret key"
},
"TenantId": {
"value": "tenant id"
},
"grantType": {
"value": "client_credentials"
}
}
}
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.
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?