Enable ARM support for API Access Keys
I would like to deploy an entire solution based on App Insights which data is presented via a Web App:
https://github.com/CatalystCode/bot-fmk-dashboard
The web app I'm deploying will use the api of app insights to display insights and aggregated data in the form of graphs and metrics.
For this to work, the web app needs to have access the app insights api and that can only be done via access keys.
I want to enable customers to deploy the application with "one click arm deployment".
Currently, after deployment, users have to create a key, copy app id and api key, open web app, create two env variables, paste values from app insights and recycle web app.
This is of course not optimal and required a lot of extra work.
Ask: Enable using Access Keys in an ARM deployment to copy the access key's value into another location (key vault / web app env vars)

Per Divya’s comment below, this can be solved by using an AAD application instead of an APIKey for access (https://docs.microsoft.com/en-us/powershell/module/azuread/new-azureadapplication?view=azureadps-2.0)
1. New-AzureADApplication
2. New-AzureADApplicationKeyCredential
3. New-AzureRmRoleAssignment where you set the Scope to the Application Insights resource
You can also manage API keys via ARM (see https://dev.applicationinsights.io/documentation/Authorization/API-key-and-App-ID to get started).
9 comments
-
Dmytry commented
This is not 'Completed'
Non of the suggestions are using ARM templates. -
Vladislav commented
The suggested workaround does not work.
According to this documentation: https://dev.applicationinsights.io/quickstart/ when using the application ID of AAD App, then an error is returned "The application could not be found".
Also, New-AzureRmRoleAssignmen returns the following error: "Principals of type Application cannot validly be used in role assignments." -
Divya Jayaraman commented
This can be solved by using an AAD application instead of an APIKey for access (https://docs.microsoft.com/en-us/powershell/module/azuread/new-azureadapplication?view=azureadps-2.0)
1. New-AzureADApplication
2. New-AzureADApplicationKeyCredential
3. New-AzureRmRoleAssignment where you set the Scope to the Application Insights resource -
Glenn Dierckx commented
I've seen on this page: https://docs.microsoft.com/en-us/azure/role-based-access-control/resource-provider-operations#microsoftinsights
That there is an operation to generate an api access key:
Microsoft.Insights/Components/ApiKeys/ActionDescription: Generating an Application Insights API key
But that's all I can find...
-
Cliff Chapman commented
Running into this issue today, it would really simplify our deployment pipeline if I could create and reference API keys in the template rather than having to run more powershell after the deploy..
-
João Lopes de Almeida commented
+1 on this one. Now that we already have Get-AzureRmApplicationInsightsApiKey, it would be great to add this into ARM deployments.
-
Mor Shemesh commented
Dale - a year later, is this feature still being worked on / reviewed?
-
jagpadda@gmail.com commented
HI,
Is ARM support for Application Insights API Key's available yet?
-
Mor Shemesh commented
Sounds great Dale!