Azure Resource Templatespecs Management Client Library for Python

1.0.0b1 · active · verified Thu Apr 09

The `azure-mgmt-resource-templatespecs` library is the Microsoft Azure Resource Templatespecs Management Client Library for Python. It allows developers to programmatically manage Azure Template Specs, which are a feature for storing, managing, and versioning Azure Resource Manager (ARM) templates as first-party Azure resources with integrated access control. The current version is 1.0.0b1, and as part of the Azure SDK for Python, it follows an active release cadence with frequent updates, often including beta releases before stable versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to authenticate with Azure and initialize the `TemplateSpecsClient` to interact with Template Specs. It uses `DefaultAzureCredential` for flexible authentication and then lists existing Template Specs by subscription. Ensure `AZURE_SUBSCRIPTION_ID` and other authentication-related environment variables are set.

import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource.templatespecs import TemplateSpecsClient

# Set environment variables for authentication and subscription:
# AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET (for service principal)
# AZURE_SUBSCRIPTION_ID

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

# Authenticate using DefaultAzureCredential
# This credential type attempts to authenticate via various methods
# (environment variables, managed identity, Azure CLI, etc.)
credential = DefaultAzureCredential()

# Create a TemplateSpecsClient
client = TemplateSpecsClient(credential=credential, subscription_id=subscription_id)

# Example: List all template specs in the subscription
print("Listing Template Specs...")
for template_spec in client.template_specs.list_by_subscription():
    print(f"  Template Spec Name: {template_spec.name}, Location: {template_spec.location}")

# Note: This is a basic example. For more complex operations like creating,
# updating, or deploying Template Specs, refer to the official Azure SDK samples.

view raw JSON →