Microsoft Azure Market Place Ordering Client Library for Python

1.1.0 · active · verified Thu Apr 09

This is the Microsoft Azure Market Place Ordering Client Library for Python, enabling management of marketplace agreements within Azure. It's part of the Azure SDK for Python and uses Azure Resource Manager (ARM) APIs. The current stable version is 1.1.0, released in March 2021. The package generally follows a stable release cadence, with updates primarily for API version bumps or minor features, reflecting the management plane operations it supports.

Warnings

Install

Imports

Quickstart

Demonstrates how to authenticate using `DefaultAzureCredential` and list marketplace agreements. Ensure `AZURE_SUBSCRIPTION_ID`, `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET` environment variables are set for authentication.

import os
from azure.identity import DefaultAzureCredential
from azure.mgmt.marketplaceordering import MarketplaceOrderingAgreements

# Set environment variables AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET, AZURE_SUBSCRIPTION_ID

sub_id = os.environ.get("AZURE_SUBSCRIPTION_ID", "")
if not sub_id:
    raise ValueError("AZURE_SUBSCRIPTION_ID environment variable not set.")

# Authenticate using DefaultAzureCredential
credential = DefaultAzureCredential()

# Create the client
client = MarketplaceOrderingAgreements(credential=credential, subscription_id=sub_id)

# Example: List marketplace agreements (this operation may require specific permissions)
# Replace 'publisherId' and 'offerId' with actual values if needed for listing or getting a specific agreement
# For simplicity, this example just attempts to list, which might be empty or require specific resources.
# Real-world usage often involves 'get' and 'create_or_update' based on a specific offer.

print("Attempting to list marketplace agreements...")
agreements = client.marketplace_agreements.list()

for agreement in agreements:
    print(f"Agreement: {agreement.name} (Publisher: {agreement.publisher_id}, Offer: {agreement.offer_id})")

print("Quickstart complete.")

view raw JSON →