{"id":1935,"library":"azure-mgmt-resource-deployments","title":"Microsoft Azure Resource Deployments Management Client Library for Python","description":"The Microsoft Azure Resource Deployments Management Client Library for Python (`azure-mgmt-resource-deployments`) provides functionality to manage Azure Resource Manager deployments. This library is currently in a beta release (1.0.0b1) and is part of the broader Azure SDK for Python, which typically follows a rapid release cadence for individual service libraries.","status":"active","version":"1.0.0b1","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","cloud","resource management","deployments","arm templates","iaas"],"install":[{"cmd":"pip install azure-mgmt-resource-deployments azure-identity","lang":"bash","label":"Install with authentication library"}],"dependencies":[{"reason":"This library is a meta-package that depends on `azure-mgmt-resource`, which provides the core `ResourceManagementClient` for deployment operations.","package":"azure-mgmt-resource","optional":false},{"reason":"Required for authentication with Azure services (e.g., DefaultAzureCredential).","package":"azure-identity","optional":false}],"imports":[{"note":"The `azure-mgmt-resource-deployments` package is a meta-package. The core client for managing deployments, `ResourceManagementClient`, is found in the `azure-mgmt-resource` package, which is a dependency.","wrong":"from azure.mgmt.resource_deployments import ResourceManagementClient","symbol":"ResourceManagementClient","correct":"from azure.mgmt.resource import ResourceManagementClient"},{"symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.resource import ResourceManagementClient\n\n# --- Setup for Quickstart ---\n# Ensure these environment variables are set for authentication and resource creation:\n# AZURE_SUBSCRIPTION_ID: Your Azure subscription ID\n# AZURE_TENANT_ID: Your Azure Active Directory tenant ID\n# AZURE_CLIENT_ID: Your Azure AD application client ID\n# AZURE_CLIENT_SECRET: Your Azure AD application client secret\n# Or log in via Azure CLI: `az login`\n\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"YOUR_SUBSCRIPTION_ID\")\nresource_group_name = os.environ.get(\"AZURE_RESOURCE_GROUP_NAME\", \"my-deployment-test-rg\")\ndeployment_name = \"mySimpleStorageDeployment\"\nlocation = os.environ.get(\"AZURE_LOCATION\", \"eastus\")\n\n# Acquire a credential object\ntry:\n    credential = DefaultAzureCredential()\nexcept Exception as e:\n    print(f\"Failed to acquire Azure credentials. Please ensure you are logged in (e.g., `az login`) or environment variables are set. Error: {e}\")\n    exit(1)\n\n# Obtain the management object (from azure.mgmt.resource, a dependency)\nresource_client = ResourceManagementClient(credential, subscription_id)\n\n# Define a simple ARM template to deploy a storage account\ntemplate_content = {\n    \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\n    \"contentVersion\": \"1.0.0.0\",\n    \"resources\": [\n        {\n            \"type\": \"Microsoft.Storage/storageAccounts\",\n            \"apiVersion\": \"2021-09-01\",\n            \"name\": f\"storagename{subscription_id[:8].replace('-','').lower()}\", # Unique name\n            \"location\": location,\n            \"sku\": {\"name\": \"Standard_LRS\"},\n            \"kind\": \"StorageV2\",\n            \"properties\": {\"supportsHttpsTrafficOnly\": True}\n        }\n    ]\n}\n\nparameters_content = {}\n\ndeployment_properties = {\n    \"mode\": \"Incremental\", \n    \"template\": template_content,\n    \"parameters\": parameters_content\n}\n\nprint(f\"Creating/Updating resource group '{resource_group_name}' if it doesn't exist...\")\nresource_client.resource_groups.create_or_update(\n    resource_group_name,\n    {\"location\": location}\n)\nprint(f\"Resource group '{resource_group_name}' ready.\")\n\nprint(f\"Initiating deployment '{deployment_name}' in resource group '{resource_group_name}'...\")\ntry:\n    poller = resource_client.deployments.begin_create_or_update(\n        resource_group_name,\n        deployment_name,\n        {\"properties\": deployment_properties}\n    )\n\n    deployment_result = poller.result()\n    print(f\"Deployment '{deployment_name}' status: {deployment_result.properties.provisioning_state}\")\n    if deployment_result.properties.provisioning_state == \"Succeeded\":\n        print(f\"Deployment successful. Resources created:\")\n        for resource in deployment_result.properties.output_resources:\n            print(f\"- {resource.id}\")\n    else:\n        print(\"Deployment failed or is in a non-succeeded state.\")\n        if deployment_result.properties.error:\n            print(f\"Error details: {deployment_result.properties.error.code} - {deployment_result.properties.error.message}\")\n\nexcept Exception as e:\n    print(f\"An error occurred during deployment: {e}\")","lang":"python","description":"This quickstart demonstrates how to create an Azure Resource Group and then deploy a simple ARM template (creating a Storage Account) using `azure-mgmt-resource-deployments`. It requires `azure-identity` for authentication and relies on `AZURE_SUBSCRIPTION_ID`, `AZURE_RESOURCE_GROUP_NAME`, and `AZURE_LOCATION` environment variables or a prior `az login`."},"warnings":[{"fix":"Use with caution in production environments. Pin to specific beta versions and test thoroughly before upgrading. Monitor release notes for breaking changes.","message":"This library is currently in beta (1.0.0b1). API signatures, types, and behaviors are subject to change without notice in future releases, potentially leading to breaking changes.","severity":"breaking","affected_versions":"All beta versions (1.x.x.bX)"},{"fix":"Always import `ResourceManagementClient` as `from azure.mgmt.resource import ResourceManagementClient`.","message":"The primary client for managing resource deployments, `ResourceManagementClient`, is imported from `azure.mgmt.resource`, not directly from `azure-mgmt-resource-deployments`. This package acts as a meta-package providing specific deployment operations within the broader resource management client.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Decide whether to use synchronous or asynchronous programming. For async, use `from azure.mgmt.resource.aio import ResourceManagementClient` and handle `await` calls correctly.","message":"Azure SDKs often provide both synchronous and asynchronous clients. The `ResourceManagementClient` (default) is synchronous. For asynchronous operations, you would typically need to import `ResourceManagementClient` from `azure.mgmt.resource.aio` and use an `async` context.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `azure-identity` is installed and environment variables required by `DefaultAzureCredential` are set, or ensure `az login` has been executed for CLI-based authentication.","message":"Authentication with Azure services requires setting up credentials correctly. Common issues include missing environment variables (`AZURE_SUBSCRIPTION_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_ID`, `AZURE_CLIENT_SECRET`) or not being logged in via `az login` for `DefaultAzureCredential` to work.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}