Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Insights Status Monitor Extension Failing to deploy with ARM template

I just started getting this failure, not sure why; it was working fine yesterday. I only changed the appsettings and connectionstrings to be part or resources instead of the webapp to move the dependsOn down the chain. Previously, the site was dependsOn the dependencies for app settings and connection strings. Here is the ARM template for the website resource.

{
        "comments": "Primary web app deployment.",
        "name": "[variables('webAppName')]",
        "type": "Microsoft.Web/sites",
        "apiVersion": "2016-08-01",
        "kind": "app",
        "location": "[variables('rgLocation')]",
        "tags": {},
        "dependsOn": [
            "[resourceId('Microsoft.Web/serverfarms', variables('planName'))]"
        ],
        "properties": {
            "enabled": true,
            "hostNameSslStates": [
                {
                    "name": "[concat(variables('webAppName'), '.azurewebsites.net')]",
                    "sslState": "Disabled"
                },
                {
                    "name": "[concat(variables('webAppName'), '.scm.azurewebsites.net')]",
                    "sslState": "Disabled"
                }
            ],
            "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('planName'))]",
            "siteConfig": {
                "numberOfWorkers": 1,
                "defaultDocuments": [
                    "Default.htm",
                    "Default.html",
                    "Default.asp",
                    "index.htm",
                    "index.html",
                    "iisstart.htm",
                    "default.aspx",
                    "index.php",
                    "hostingstart.html"
                ],
                "netFrameworkVersion": "v4.6",
                "phpVersion": "",
                "pythonVersion": "",
                "nodeVersion": "",
                "linuxFxVersion": "",
                "requestTracingEnabled": false,
                "remoteDebuggingEnabled": false,
                "remoteDebuggingVersion": "VS2015",
                "httpLoggingEnabled": false,
                "logsDirectorySizeLimit": 35,
                "detailedErrorLoggingEnabled": false,
                "scmType": "None",
                "use32BitWorkerProcess": false,
                "webSocketsEnabled": false,
                "alwaysOn": true,
                "managedPipelineMode": "Integrated",
                "virtualApplications": [
                    {
                        "virtualPath": "/",
                        "physicalPath": "site\\wwwroot",
                        "preloadEnabled": false
                    }
                ],
                "autoHealEnabled": false,
                "vnetName": ""
            },
            "microService": "WebSites",
            "clientAffinityEnabled": false,
            "clientCertEnabled": false,
            "hostNamesDisabled": false
        },
        "resources": [
            {
                "name": "appsettings",
                "type": "config",
                "apiVersion":"2015-08-01",
                "dependsOn":[
                    "[resourceId('Microsoft.Web/sites', variables('webAppName'))]",
                    "[resourceId('microsoft.insights/components', variables('insightsName'))]"
                ],
                "properties": {
                    "APPINSIGHTS_INSTRUMENTATIONKEY":"[reference(resourceId('Microsoft.Insights/components', variables('insightsName')), '2015-05-01').InstrumentationKey]",
                    "UseAzureStorageEmulator": "false"
                }
            },
            {
                "name": "connectionstrings",
                "type": "config",
                "apiVersion":"2015-08-01",
                "dependsOn":[
                    "[resourceId('Microsoft.Web/sites', variables('webAppName'))]",
                    "[resourceId('Microsoft.Storage/storageAccounts', variables('genStorageName'))]",
                    "[resourceId('Microsoft.Storage/storageAccounts', variables('jobStorageName'))]"
                ],
                "properties": {
                    "AzureStorage": {
                        "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('genStorageName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('genStorageName')), '2017-06-01').keys[0].value, ';EndpointSuffix=core.windows.net')]",
                        "type": "Custom"
                    },
                    "AzureWebJobsDashboard" : {
                        "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('jobStorageName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('jobStorageName')), '2017-06-01').keys[0].value, ';EndpointSuffix=core.windows.net')]",
                        "type": "Custom"
                    },
                    "AzureWebJobsStorage" : {
                        "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('jobStorageName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('jobStorageName')), '2017-06-01').keys[0].value, ';EndpointSuffix=core.windows.net')]",
                        "type": "Custom"
                    }
                }
            },
            {
                "apiVersion":"2015-08-01",
                "name": "Microsoft.ApplicationInsights.AzureWebSites",
                "type": "siteextensions",
                "dependsOn": [
                    "[resourceId('Microsoft.Web/Sites', variables('webAppName'))]"
                ],
                "properties": {}
            }
        ]
    }

And the error I'm getting...

STATUS Conflict
PROVISIONING STATE Failed
TIMESTAMP7/14/2017, 10:40:23 AM
DURATION 1 minute 46 seconds
TYPE Microsoft.Web/sites/siteextensions
RESOURCE ID /subscriptions/.../providers/Microsoft.Web/sites/.../siteextensions/Microsoft.ApplicationInsights.AzureWebSites
STATUSMESSAGE{
    "status": "Canceled",
    "error": {
        "code": "ResourceDeploymentFailure",
        "message": "The resource operation completed with terminal provisioning state 'Canceled'."
    }
}

Even with the error, it actually did install the extension correctly. During another test, it installed the extension, but when I opened it, the App Insights Profiler web job was not installed. Either way, not sure why there is a conflict. When I open the log in Kudu, there is pretty much nothing inside.

7/14/2017 2:44:38 PM: [Verbose] Starting Application Insights installation and configuration...
7/14/2017 2:44:38 PM: [Verbose] Loading assembly from D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\Microsoft.ApplicationInsights.WebSiteManager.dll
7/14/2017 2:44:39 PM: [Verbose] No web.config detected. The web app may be empty. Assume classic ASP.NET by default.

That's the entirety of the log.

On a previous test...

7/13/2017 6:15:44 PM: [Verbose] Starting Application Insights installation and configuration...
7/13/2017 6:15:44 PM: [Verbose] Loading assembly from D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\Microsoft.ApplicationInsights.WebSiteManager.dll
7/13/2017 6:15:44 PM: [Verbose] No web.config detected. The web app may be empty. Assume classic ASP.NET by default.

Same start of the file, but there are more entries. There is definitely a web config and the app is working so not sure what that's about.

7/13/2017 6:15:50 PM: [Verbose] Application is not instrumented with Application Insights.
7/13/2017 6:15:50 PM: [Verbose] Starting to download/install 'Microsoft.ApplicationInsights.Azure.WebSites' nuget package from D:\home\SiteExtensions\Microsoft.ApplicationInsights.AzureWebSites\appinsights...
7/13/2017 6:15:52 PM, [Verbose] Installing 'Microsoft.ApplicationInsights', version '2.3.0' ...
7/13/2017 6:15:53 PM, [Verbose] Installed 'Microsoft.ApplicationInsights', version '2.3.0'.

The app is definitely instrumented and uses version 2.4 which is newer than 2.3 which was installed.

like image 315
MPavlak Avatar asked Jul 14 '17 15:07

MPavlak


People also ask

How to integrate application Insights?

Add Application Insights automatically From within your ASP.NET web app project in Visual Studio: Select Project > Add Application Insights Telemetry > Application Insights Sdk (local) > Next > Finish > Close.

How appinsight works?

The instrumentation monitors your app and directs the telemetry data to an Application Insights resource by using a unique token. The effect on your app's performance is small; tracking calls are non-blocking and batched to be sent in a separate thread.

What is telemetry in application Insights?

Application Insights telemetry model defines a way to correlate telemetry to the operation of which it's a part. For example, a request can make a SQL Database calls and recorded diagnostics info. You can set the correlation context for those telemetry items that tie it back to the request telemetry.

How to View application Insights telemetry?

View telemetry in Application InsightsSelect Application Insights under Settings in the left page. If this is your first time using Application Insights with your subscription, you'll be prompted to enable it. To do this, select Turn on Application Insights, and then select Apply on the next page.


1 Answers

There seems to be no way to make the extension wait on app setting update so I moved the installation of the extension into a different task in the release environment. Now I have three tasks:

1.  ARM deploy common resources
2.  ARM deploy app dependencies and app service
3.  ARM deploy status monitor site extension
4.  Web Deploy code into app service

However, in order to do this, you have to still specify the website somehow in step 3.

Here is what I did using the output from step 2 which has the webAppName, I had to specify the site again and then place the extension into the resources for that site. You must be careful about what you specify here as to not disrupt the previous deployment.

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "webAppName": { "type": "string", "value": "<outputfrompreviousstep>" }
    },
    "variables": {
        "planName": "[concat(variables('webAppName'), '-ServicePlan')]"
    },
    "resources": [
        {
            "name": "[variables('webAppName')]",
            "type": "Microsoft.Web/sites",
            "apiVersion": "2016-08-01",
            "location": "[resourceGroup().location]",
            "tags": {},
            "dependsOn": [
            ],
            "properties": {
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('planName'))]"
            },
            "resources": [
                {
                    "apiVersion":"2015-08-01",
                    "name": "Microsoft.ApplicationInsights.AzureWebSites",
                    "type": "siteextensions",
                    "dependsOn": [
                        "[resourceId('Microsoft.Web/Sites', variables('webAppName'))]"
                    ],
                    "properties": {}
                }
            ]
        }
    ],
    "outputs": {
        "webAppName": {
            "type": "string",
            "value": "[variables('webAppName')]"
        }
    }
}
like image 51
MPavlak Avatar answered Sep 20 '22 12:09

MPavlak