Associate monitoring with Azure App Service using Azure CLI

Associate monitoring with Azure App Service using Azure CLI

Install Azure CLI

If you haven't already, install Azure CLI on your local machine by following the instructions provided by Microsoft at https://docs.microsoft.com/cli/azure/install-azure-cli

Log in to Azure

Open a terminal or command prompt and log in to your Azure account by running the following command:

az login

Associate monitoring with Azure App Service using Azure CLI

Set the subscription

If you have multiple Azure subscriptions, set the one you want to use for your App Service monitoring by running the following command:

az account set --subscription <subscription_id>

You can extract the subscription id from the above-given login command output.

Enable Application Insights

Application Insights is a monitoring and diagnostics service in Azure. To enable it for your App Service, run the following command:

az webapp config set --name <app_service_name> --resource-group <resource_group_name> --enabled true --slot-settings

Replace <app_service_name> with the desired name of your App Service and <resource_group_name> with the name of the resource group where your App Service is located.

Verify monitoring setup

To confirm that the monitoring has been enabled for your App Service, you can check the configuration by running the following command:

az webapp config show --name <app_service_name> --resource-group <resource_group_name> --query instrumentationKey

This command will return the Instrumentation Key, which you can use to integrate your App Service with monitoring tools like Azure Monitor and Application Insights.

All done! You have now associated monitoring with your Azure App Service using Azure CLI. You can use the obtained Instrumentation Key to configure additional monitoring settings or integrate with other monitoring services as per your requirements.

Happy learning!