The `azure-mgmt-containerinstance` library provides a client for managing Azure Container Instances, allowing programmatic creation, update, and deletion of container groups and related resources. It is part of the larger Azure SDK for Python and is currently at version 10.1.0, with frequent updates aligning with Azure service API changes and broader SDK release cycles.
pip install azure-mgmt-containerinstance azure-identityVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to authenticate with `DefaultAzureCredential` and create a simple Azure Container Instance (ACI) using the `ContainerInstanceManagementClient`. It sets up a container group with a single public-facing container running a hello-world image. Remember to set your Azure Subscription ID, Resource Group Name, and Location in environment variables or directly in the script.
Use `from azure.identity import DefaultAzureCredential` for authentication and initialize the client directly with `ContainerInstanceManagementClient(credential, subscription_id)`.
Update calls to `client.container_groups.begin_create_or_update` to use `resource_group_name_param` instead of `resource_group_name`.
Always call `.result()` on the poller object (e.g., `lro_poller.result()`) to wait for the operation to complete and retrieve the final resource object or status in synchronous clients. For asynchronous clients, you'd `await` the poller methods.
Ensure the resource group exists before attempting to deploy container instances into it. You might need to use `azure-mgmt-resource` to create resource groups programmatically if they don't exist.
Ensure the `AZURE_SUBSCRIPTION_ID` environment variable is correctly set in your environment before running the application. This is essential for the Azure SDK to identify which subscription to operate on.
Ensure all required environment variables, such as `AZURE_SUBSCRIPTION_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, and `AZURE_CLIENT_SECRET`, are properly configured before running the script. These are essential for authentication and identifying the target Azure subscription. You can set them using `export AZURE_SUBSCRIPTION_ID='your-subscription-id'` in your shell or similar methods depending on your environment.