Azure Deployment Stacks Management
The `azure-mgmt-resource-deploymentstacks` library is the Microsoft Azure Resource Deployment Stacks Management Client Library for Python (version 1.0.0). It provides programmatic access to manage Azure Deployment Stacks, a native Azure resource type designed for managing collections of Azure resources as a single unit across different management scopes. This package is part of the broader Azure SDK for Python and supports Python 3.9+.
Warnings
- breaking The functionality for Deployment Stacks was moved from `azure-mgmt-resource` to its own dedicated package, `azure-mgmt-resource-deploymentstacks`, starting with `azure-mgmt-resource` version 24.0.0. This requires updating import statements.
- breaking This package, like other new Azure SDK management libraries, now exclusively targets the *latest* API-Version available on Azure. Older API versions are no longer supported directly within this package.
- breaking The credential system has been completely revamped. Legacy `azure.common.credentials` or `msrestazure.azure_active_directory` instances are no longer supported for authentication.
- deprecated Azure Deployment Stacks are the successor to Azure Blueprints. Azure Blueprints will be deprecated by July 2026, and customers are advised to migrate their blueprint definitions and assignments to Template Specs and Deployment Stacks.
- gotcha Azure SDK Python packages ended support for Python 2.7 on January 1, 2022.
Install
-
pip install azure-mgmt-resource-deploymentstacks azure-identity
Imports
- DeploymentStacksClient
from azure.mgmt.resource.deploymentstacks import DeploymentStacksClient
Quickstart
import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource.deploymentstacks import DeploymentStacksClient
# Set environment variables for authentication:
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET for Service Principal/OAuth
# AZURE_SUBSCRIPTION_ID for the target subscription
subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not subscription_id:
print("Please set the AZURE_SUBSCRIPTION_ID environment variable.")
exit(1)
# Authenticate using DefaultAzureCredential, which attempts various methods
# (e.g., environment variables, managed identity, Azure CLI).
credential = DefaultAzureCredential()
# Create a Deployment Stacks client
client = DeploymentStacksClient(credential=credential, subscription_id=subscription_id)
# Example: List all deployment stacks in the current subscription
print(f"Listing deployment stacks for subscription: {subscription_id}")
try:
for stack in client.deployment_stacks.list_at_subscription_scope():
print(f"- Name: {stack.name}, Resource Group: {stack.resource_group}")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure your credentials have 'Microsoft.Resources/deploymentStacks/read' permission.")
print("\nQuickstart finished.")