Azure / azure-quickstart-templates

Azure Quickstart Templates
https://aka.ms/azqst
MIT License
14.06k stars 16.12k forks source link

Webtests deployment not working #5771

Open JeffreyGarrett opened 5 years ago

JeffreyGarrett commented 5 years ago

[Template Name goes here](Template link goes here) dynamic-web-tests https://github.com/Azure/azure-quickstart-templates/tree/c99d83208f566f75bcd3301e645f5982c4b0a7c3/201-dynamic-web-tests

Issue Details

When deploying the template (after changing the values) the webtests deployment fails. The error we get is a basic request with no detail BadRequest

Repro steps

  1. Fill in the parameters file as needed
  2. deploy to azure you'll notice that the appinsights will succeed and the web test will fail.

template

    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appName": {
            "type": "String",
            "metadata": {
                "description": "The name of the app insights instance that you wish to create."
            }
        },
        "tests": {
            "type": "Array",
            "metadata": {
                "description": "The list of web tests to run. See the README for the schema of test descriptor object."
            }
        },
        "emails": {
            "type": "Array",
            "metadata": {
                "description": "A list of strings representing the email addresses to send alerts to."
            }
        },
        "location": {
            "defaultValue": "[resourceGroup().location]",
            "type": "String",
            "metadata": {
                "description": "Location for all resources."
            }
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "microsoft.insights/components",
            "kind": "web",
            "name": "[parameters('appName')]",
            "apiVersion": "2015-05-01",
            "location": "[parameters('location')]",
            "tags": {
                "AppInsightsApp": "MyApp"
            },
            "properties": {
                "Application_Type": "web",
                "Flow_Type": "Redfield",
                "Request_Source": "Unknown",
                "Name": "testapp",
                "ApplicationId": "[parameters('appName')]"
            }
        },
        {
            "type": "microsoft.insights/webtests",
            "name": "[parameters('tests')[0].name]",
            "apiVersion": "2015-05-01",
            "location": "[parameters('location')]",
            "tags": {
                "[concat('hidden-link:', resourceId('microsoft.insights/components/', parameters('appName')))]": "Resource"
            },
            "properties": {
                "Name": "[parameters('tests')[0].name]",
                "Description": "[parameters('tests')[0].description]",
                "Enabled": true,
                "Frequency": "[parameters('tests')[0].frequency_secs]",
                "Timeout": "[parameters('tests')[0].timeout_secs]",
                "Kind": "ping",
                "Locations": "[parameters('tests')[0].locations]",
                "Configuration": {
                    "WebTest": "[concat('<WebTest Name=\"', parameters('tests')[0].name, '\"',  ' Id=\"', parameters('tests')[0].guid ,'\"    Enabled=\"True\" CssProjectStructure=\"\" CssIteration=\"\" Timeout=\"0\" WorkItemIds=\"\" xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\" Description=\"\" CredentialUserName=\"\" CredentialPassword=\"\" PreAuthenticate=\"True\" Proxy=\"default\" StopOnError=\"False\" RecordedResultFile=\"\" ResultsLocale=\"\">        <Items>        <Request Method=\"GET\" Guid=\"a5f10126-e4cd-570d-961c-cea43999a200\" Version=\"1.1\" Url=\"', parameters('tests')[0].url ,'\" ThinkTime=\"0\" Timeout=\"300\" ParseDependentRequests=\"True\" FollowRedirects=\"True\" RecordResult=\"True\" Cache=\"False\" ResponseTimeGoal=\"0\" Encoding=\"utf-8\" ExpectedHttpStatusCode=\"', parameters('tests')[0].expected ,'\" ExpectedResponseUrl=\"\" ReportingName=\"\" IgnoreHttpStatusCode=\"False\" /></Items></WebTest>')]"
                },
                "SyntheticMonitorId": "[parameters('tests')[0].name]"
            },
            "dependsOn": [
                "[concat('microsoft.insights/components/', parameters('appName'))]"
            ]
        },
        {
            "type": "Microsoft.Insights/alertRules",
            "name": "[concat(parameters('tests')[0].name, 'alert')]",
            "apiVersion": "2015-04-01",
            "location": "[parameters('location')]",
            "tags": {
                "[concat('hidden-link:', resourceId('microsoft.insights/components/', parameters('appName')))]": "Resource",
                "[concat('hidden-link:', resourceId('microsoft.insights/webtests/', parameters('tests')[0].name))]": "Resource"
            },
            "properties": {
                "name": "[parameters('tests')[0].name]",
                "description": "[parameters('tests')[0].description]",
                "isEnabled": true,
                "condition": {
                    "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.LocationThresholdRuleCondition, Microsoft.WindowsAzure.Management.Mon.Client",
                    "odata.type": "Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition",
                    "dataSource": {
                        "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleMetricDataSource, Microsoft.WindowsAzure.Management.Mon.Client",
                        "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
                        "resourceUri": "[resourceId('microsoft.insights/webtests/', parameters('tests')[0].name)]",
                        "metricName": "GSMT_AvRaW"
                    },
                    "windowSize": "PT15M",
                    "failedLocationCount": "[parameters('tests')[0].failedLocationCount]"
                },
                "action": {
                    "$type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.RuleEmailAction, Microsoft.WindowsAzure.Management.Mon.Client",
                    "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
                    "sendToServiceOwners": true,
                    "customEmails": "[parameters('emails')]"
                }
            },
            "dependsOn": [
                "[concat('microsoft.insights/components/', parameters('appName'))]",
                "[concat('microsoft.insights/webtests/', parameters('tests')[0].name)]"
            ]
        }
    ]
}

parameters

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "appName": {
            "value": "GEN-UNIQUE"
        },
        "tests": {
            "value": [
                {
                    "name": "GEN-UNIQUE-8",
                    "url": "http://www.microsoft.com",
                    "expected": 200,
                    "frequency_secs": 300,
                    "timeout_secs": 30,
                    "failedLocationCount": 1,
                    "description": "a description for test1",
                    "guid": "GEN-GUID",
                    "locations": [
                        {
                            "Id": "us-il-ch1-azr"
                        }
                    ]
                }
            ]
        },
        "emails": {
            "value": [
                "jeff@websystem3.com"
            ]
        },
        "location": {
            "value": "eastus"
        }
    }
}

Please let me know what else you need.

leandroscardua commented 5 years ago

I have the same issue. does anyone know about that?

marlonsingleton commented 5 years ago

@JeffreyGarrett and @leandroscardua looks like the issue is with Application Insights once Availability Test are added to the deployment.

After adding availability test to any deployment I create, I get the following:

Deployment failed. Correlation ID: an ID string here. { "code": "BadRequest", "message": "Bad Request", "innererror": { "diagnosticcontext": "context value here", "time": "2019-02-20T07:50:10.9359978Z" } }

I notice some warning headers here that allude to namespace changes in Azure Monitor, which now houses Application Insights:

Get-AzureRmLog -CorrelationId "ID string here" WARNING: 8:02:49 AM - ** The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models infuture releases. WARNING: 8:02:49 AM - The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes. WARNING: [Get-AzLog] Parameter deprecation: The DetailedOutput parameter will be deprecated in a future breaking change release.**

Maybe someone from Microsoft will chime in with more information or forward this information to the appropriate team.

hosseinjayride commented 5 years ago

Any update on this? I have the same issue here. @marlonsingleton are you saying that template has been put there without being tested or is it recently breaking because of another change?

marlonsingleton commented 5 years ago

I'm sure the template worked at the time of creation. The issue is likely due to another change. More specifically, at the time of my post, I also encountered issues deploying Availability Tests directly from the portal. @hosseinjayride have you tested from the portal?

leandroscardua commented 5 years ago

Hi Guys,

I don't have any update :( I tried to use API instead powershell script. I'm having the same problem ...

On Mon, Mar 25, 2019, 6:03 AM Marlon Singleton, notifications@github.com wrote:

I'm not implying that at all. I'm sure the template worked at the time of creation. More specifically, at the time of my post, I encountered issues deploying Availability Tests directly from the portal as well. @hosseinjayride https://github.com/hosseinjayride have you tested from the portal?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Azure/azure-quickstart-templates/issues/5771#issuecomment-476128054, or mute the thread https://github.com/notifications/unsubscribe-auth/AXjerYqSfZkGCLivVCktKVK98N4vV06Mks5vaJ70gaJpZM4akRds .

marlonsingleton commented 5 years ago

Azure Portal > Help + Support > New Support Request or utilize your company's Azure support plan to investigate further. << My humble suggestion

hosseinjayride commented 5 years ago

Thanks @marlonsingleton for your reply. Actually, the issue for me was that I used the webtest tempate in this github quickstart-templates in conjunction with my own template. What I had was that I had my app insights deployed using "linked" template and the webtest from this repo. Turned out webtest deployment failed because the app insight was not deployed "directly" with the same template deployment.

I copied and pasted the template and the parameters, and deployed to a new resource group without changing anything or using linked template and it worked. So, nothing wrong with the template. Thanks.

However, for those who still have the issue (@JeffreyGarrett @leandroscardua ):

  1. Put all webtest deployment, alert, and app insight in one template and don't use linked templates.
  2. If you still have the issue or your issue is not linked templates, create all your resources (app insight, webtest, and the alert) in the Portal manually in a new resource group and then in "All services" section of Portal, search for "Resource Explorer". In the Resource Explorer, navigate to each resource in the Subscriptions tree menu and extract the template for each resource one by one. There will be a lot of hard-coded strings within those templates. If you want, you can change them to [resourceId(...)] or [parameters(...)] or anything that fits your needs. Also, these templates do not have "dependsOn". Don't forget to put them in. Shouldn't be hard to figure out dependencies.
marlonsingleton commented 5 years ago

@hosseinjayride I'm glad you were able to successfully deploy along with webtest.

pekspro commented 4 years ago

I was also struggling with this template, I got the following error message during deployment:

You cannot create or modify classic metric alerts for this subscription as this subscription

Classic alerts are no longer supported, so that’s no surprise. I hope this template get updated someday. I found some good documentation here that I used to resolve my problem:

https://docs.microsoft.com/sv-se/azure/azure-monitor/platform/alerts-metric-create-templates#template-for-an-availability-test-along-with-a-metric-alert