Microsoft Azure Resource Deploymentscripts Management Client Library for Python

1.0.0b1 · active · verified Thu Apr 09

This is the Microsoft Azure Resource Deploymentscripts Management Client Library for Python. It provides capabilities to manage deployment scripts within Azure Resource Manager (ARM) templates, allowing for custom steps like adding users, performing data plane operations, or creating self-signed certificates during deployments. The current version is 1.0.0b1, indicating a beta release. Azure SDK for Python packages, including beta releases, are published to PyPI regularly, reflecting active development.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `DeploymentScriptsClient` using `DefaultAzureCredential` for authentication. It requires the `AZURE_SUBSCRIPTION_ID` environment variable to be set, along with other Azure Active Directory environment variables for `DefaultAzureCredential` to function correctly (e.g., `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`). For local development, `az login` can often provide the necessary credentials. The example includes a placeholder for listing deployment scripts.

import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource.deploymentscripts import DeploymentScriptsClient

# Set environment variables for authentication and subscription ID:
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
# AZURE_SUBSCRIPTION_ID
# For local development, `DefaultAzureCredential` can often pick up credentials from `az login`.

subscription_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "YOUR_SUBSCRIPTION_ID")

if subscription_id == "YOUR_SUBSCRIPTION_ID":
    print("WARNING: Please set the AZURE_SUBSCRIPTION_ID environment variable for a functional example.")

try:
    credential = DefaultAzureCredential()
    client = DeploymentScriptsClient(credential=credential, subscription_id=subscription_id)

    print(f"DeploymentScriptsClient initialized successfully for subscription: {subscription_id}")

    # Example: List deployment scripts (uncomment to run)
    # print("Listing deployment scripts...")
    # for script in client.deployment_scripts.list_by_subscription():
    #     print(f"- Script Name: {script.name}, Resource Group: {script.id.split('/')[4]}")

    # To create, update, or delete deployment scripts, refer to the official Azure SDK samples
    # for detailed usage of `client.deployment_scripts.begin_create_or_update` or other operations.

except Exception as e:
    print(f"An error occurred during client initialization or operation: {e}")
    print("Please ensure you are authenticated to Azure (e.g., `az login`) and AZURE_SUBSCRIPTION_ID is set.")

view raw JSON →