Microsoft Azure Client Runtime (msrestazure)

0.6.4 · maintenance · verified Sun Mar 29

msrestazure provides Azure-specific functionality for the AutoRest-generated Python client runtime (`msrest`). It extends `msrest` with features like Azure Long-Running Operations (LRO) polling, Azure-specific authentication credentials, and error handling for Azure services. It is a foundational component for older versions of the Azure SDK for Python, with the current version being 0.6.4.post1. Its release cadence has been infrequent since 2020.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the use of `msrestazure.tools` for parsing and validating Azure resource IDs, a common utility provided by the library. While `msrestazure` is primarily a low-level runtime for AutoRest-generated clients, these utility functions are directly usable.

from msrestazure.tools import parse_resource_id, is_valid_resource_id

# msrestazure provides utility functions for working with Azure resource IDs.
resource_id = "/subscriptions/subId/resourceGroups/rgName/providers/Microsoft.Compute/virtualMachines/vmName"
parsed_id = parse_resource_id(resource_id)

print(f"Original Resource ID: {resource_id}")
print(f"Subscription: {parsed_id.get('subscription')}")
print(f"Resource Group: {parsed_id.get('resource_group')}")
print(f"Provider: {parsed_id.get('resource_provider')}")
print(f"Resource Name: {parsed_id.get('resource_name')}")

print(f"\nIs valid resource ID '{resource_id}': {is_valid_resource_id(resource_id)}")
invalid_id = "/subscriptions/subId/resourceGroups/rgName/invalid"
print(f"Is valid resource ID '{invalid_id}': {is_valid_resource_id(invalid_id)}")

view raw JSON →