Registry / azure / azure-mgmt-applicationinsights

azure-mgmt-applicationinsights

JSON →
library4.1.0pypypi✓ verified 25d ago

The `azure-mgmt-applicationinsights` library is the Microsoft Azure Application Insights Management Client for Python, providing programmatic access to manage Application Insights resources. It allows you to create, update, delete, and list Application Insights components and related entities. As part of the Azure SDK for Python, it follows a regular release cadence, with the current stable version being 4.1.0.

pip install azure-mgmt-applicationinsights azure-identity
INSTALL
IMPORT
SIG · AZURE-MGMT-APPLICA
A
azure-mgmt-applicationinsights
azurepythonv4.1.0
Install
4.2s avg
Import
552ms
Disk
50MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.1.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.588s · 50.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.2s · import 0.516s · 51MB
50MB installed
● package 50MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ApplicationInsightsManagementClient
from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient
DefaultAzureCredential
from azure.identity import DefaultAzureCredential
from msrestazure.azure_exceptions import CloudError
While CloudError is still relevant for error handling, DefaultAzureCredential is the modern and recommended way to get credentials, replacing older `msrestazure` based credential types.

This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then list all Application Insights components within a specified Azure subscription using `ApplicationInsightsManagementClient`. It's crucial to set the `AZURE_SUBSCRIPTION_ID` environment variable or replace the placeholder.

import os from azure.identity import DefaultAzureCredential from azure.mgmt.applicationinsights import ApplicationInsightsManagementClient # Ensure you have your Azure Subscription ID set as an environment variable or hardcoded. # For a production environment, use environment variables or Azure Key Vault. subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "YOUR_SUBSCRIPTION_ID") if not subscription_id or subscription_id == "YOUR_SUBSCRIPTION_ID": raise ValueError("AZURE_SUBSCRIPTION_ID environment variable is required for this example.") # Authenticate with Azure using DefaultAzureCredential. # This credential type attempts to authenticate through multiple methods, # including environment variables (AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID), # managed identity, Visual Studio Code, Azure CLI, etc. credential = DefaultAzureCredential() # Create an Application Insights Management Client client = ApplicationInsightsManagementClient(credential, subscription_id) # Example: List all Application Insights components in the subscription print("Listing all Application Insights components in the subscription...") try: for component in client.components.list(): print(f" - Name: {component.name}, Resource Group: {component.resource_group_name}, Location: {component.location}, Kind: {component.kind}") print("\nSuccessfully listed Application Insights components.") except Exception as e: print(f"An error occurred: {e}") print("Please ensure your AZURE_SUBSCRIPTION_ID is correct and your credentials have 'Reader' role on the subscription.")
Debug
Known issues
breakingMajor breaking changes occurred during the transition from 'Track 1' (older `msrestazure`-based) to 'Track 2' (modern `azure-core`-based) versions of Azure SDK libraries. `azure-mgmt-applicationinsights` v4.x.x is a Track 2 library.
fix
Code written for older SDK versions (e.g., v0.x.x, v1.x.x) will likely require significant updates. Key changes include client constructor signatures, parameter names, return types (especially for pagination), and the use of `azure-identity` for authentication instead of `msrestazure` specific credential classes.
affects: <4.0.0
deprecatedOlder authentication methods (e.g., `ServicePrincipalCredentials` from `msrestazure`) are deprecated in favor of the `azure-identity` library.
fix
Migrate your authentication code to use `azure.identity.DefaultAzureCredential` or other specific credential types from `azure-identity`. `DefaultAzureCredential` provides a robust and flexible way to authenticate in various environments.
affects: <4.0.0
gotchaList operations in modern Azure SDK (Track 2) libraries often return async iterators directly, differing from older SDKs that might have returned a `Paged` object or required explicit calls to `by_page()`.
fix
For list operations (e.g., `client.components.list()`), you can often iterate directly over the returned object. If you need explicit pagination control or are working in an asynchronous context, refer to the method signature for `by_page()` or `async_by_page()` methods if available, though direct iteration is common for simplicity.
affects: <4.0.0
gotchaMany Azure SDK examples and library operations (especially those involving resource management) require the AZURE_SUBSCRIPTION_ID environment variable to be set for proper authentication and targeting of resources.
fix
Set the AZURE_SUBSCRIPTION_ID environment variable in your environment before running examples or applications that interact with Azure resources. For example: `export AZURE_SUBSCRIPTION_ID="your-subscription-id"`.
affects: all
gotchaThe example or library usage requires environment variables like `AZURE_SUBSCRIPTION_ID` for authentication and resource management. These must be set for the code to run successfully.
fix
Ensure that all necessary environment variables for Azure authentication and resource management (e.g., `AZURE_SUBSCRIPTION_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_TENANT_ID`) are properly configured in your environment before running the code.
affects: *
Upgrade
Version history
4.1.0latest on PyPI · released Mar 6, 2025
Audit
Dependencies
azure-corerequiredProvides shared primitives, exceptions, and base client for all Azure SDK libraries.
azure-mgmt-corerequiredCore functionality for Azure Management SDK clients.
azure-identityrequiredRecommended library for Azure authentication using various credential types.
msrestazurerequiredProvides Azure-specific extensions for msrest, used for HTTP client and serialization.
Agent activity
39 hits · last 30 days
node
34
Amazon
1
OpenAI (training)
1
Resources