David
David

Reputation: 1293

Azure CLI Bash - attaching an app insights resource to api managment

I can create an api management instance

    az apim create \
        --name "$apimName" \
        --resource-group "$resourceGroupName" \
        --publisher-name 'Publisher' \
        --publisher-email '[email protected]' \
        --tags "${resourceTags[@]}"

and I can create an app insights instance

    az monitor app-insights component create \
        --app "${apimName}-appins" \
        --location "australiaeast" \
        --resource-group "$resourceGroupName" \
        --tags "${resourceTags[@]}"

How do I attach the api insights to api management?

Upvotes: 1

Views: 420

Answers (1)

Joy Wang
Joy Wang

Reputation: 42053

Try the command below, replace the values with yours.

az resource create --resource-type 'Microsoft.ApiManagement/service/loggers' -g '<apim-group-name>' -n '<apim-name>/loggers/<appinsight-name>' --properties '{
    "loggerType":"applicationInsights",
    "description": null,
    "credentials": {
      "instrumentationKey": "<Instrumentation-Key-of-your-appinsight>"
    },
    "isBuffered": true,
    "resourceId": "/subscriptions/<subscription-id>/resourceGroups/<appinsight-group-name>/providers/microsoft.insights/components/<appinsight-name>"
}'

enter image description here

enter image description here

Upvotes: 3

Related Questions