Azure SDK for Python

repository·main·Indexed 26 days ago

https://github.com/azure/azure-sdk-for-python

A collection of client and management libraries for programmatically managing resources and consuming Azure cloud services. The repository includes tools for smoke testing across services like Key Vault, Storage, Event Hubs, and Cosmos DB, as well as the azpysdk CLI tool.

Tokens
335.5K
Snippets
1.1K
Records
1.4K
Agent score
91%

What's inside azure-sdk-for-python

  1. Overview of Azure AI Inference capabilities

    main

    The Azure AI Inference client library (currently in preview) allows you to interact with AI models across multiple services including GitHub Models, Azure AI Foundry (Serverless/Managed Compute), and Azure OpenAI.

    Key capabilities include:

    • Authentication: Authenticate against various AI services.
    • Model Information: Retrieve metadata about the deployed AI model.
    • Chat Completions: Perform conversational AI tasks.
    • Text Embeddings: Generate vector representations of text.
    • Image Embeddings: Generate vector representations of images.

    Note: While you can use this library for Azure OpenAI to compare performance with other models, it is recommended to use the official openai Python library for production Azure OpenAI implementations.

  2. Overview of Azure AI Projects client capabilities

    main

    The AIProjectClient provides access to various resource groups in a Microsoft Foundry Project:

    • Agents: Create and run Agents (including Hosted Agents) via .agents.
    • Tools: Enhance agents with tools like Azure AI Search, Code Interpreter, and more via .toolboxes.
    • OpenAI Integration: Get an OpenAI client via .get_openai_client() for Responses and Fine-Tuning.
    • Resource Management: Enumerate deployments (.deployments), connections (.connections), and search indexes (.indexes).
    • Data Management: Upload documents and create datasets via .datasets.
    • Evaluation: Assess generative AI performance using .evaluation_rules, .beta.evaluation_taxonomies, .beta.evaluators, .beta.insights, and .beta.schedules.
    • Preview Features: Access experimental features via the .beta sub-client, such as .beta.memory_stores, .beta.models, .beta.red_teams, .beta.routines, and .beta.skills.

    Note on Preview Features: To use Preview features available through stable methods, you must set allow_preview=True when constructing the client. Features in the .beta sub-clients do not require this flag.

  3. Overview of Azure Event Hubs Python Samples

    main

    The Azure Event Hubs client library for Python provides both synchronous and asynchronous versions of its API. This repository contains code samples covering common scenarios including client creation, sending events, receiving events, and authentication methods.

    Important Note on Concurrency: EventHub clients are not thread-safe or coroutine-safe. You must manage concurrency by ensuring a single client instance is not accessed simultaneously by multiple threads or coroutines.

  4. Overview of Azure SDK Tools

    main

    The azure-sdk-tools package is designed for use within the azure-sdk-for-python repository. It provides automation utilities for building packages, managing versions, running tests, and parsing package metadata.

    Important Note: Most script entrypoints should be executed from within the azure-sdk-for-python repository root. If you are running them from a different directory, you must provide the --repo argument pointing to the repository root.

  5. Overview of Azure AI Content Understanding

    main

    Azure AI Content Understanding is a multimodal AI service designed to extract semantic content from documents, video, audio, and image files. It converts unstructured content into structured, machine-readable data suitable for retrieval-augmented generation (RAG) and automated workflows.

    Key capabilities include:

    • Document Extraction: Extract text, tables, figures, layout information, and structured markdown from PDFs, images (including handwriting), and Office documents.
    • Audio Analysis: Transcribe audio with speaker diarization and timing information.
    • Video Analysis: Extract visual frames, transcribe audio, and generate structured summaries.
    • Prebuilt Analyzers: Access production-ready analyzers for finance (invoices, receipts), identity (passports, licenses), mortgage (loan applications), procurement (purchase orders), and utilities.
    • Custom Analyzers: Build domain-specific analyzers for documents, video, audio, and images.
    • Classification: Automatically categorize documents and video by type.
  6. Overview of Azure Monitor OpenTelemetry Distro Samples

    main

    The following samples demonstrate various ways to use the Azure Monitor OpenTelemetry distribution for logging, metrics, and tracing:

    Logging Samples

    • logging/basic.py: Produce logs using basic logging configurations.
    • logging/correlated_logs.py: Produce logs correlated with spans.
    • logging/custom_event.py: Produce custom events using logs.
    • logging/custom_properties.py: Add custom properties to logs.
    • logging/exception_logs.py: Produce exception logs.
    • logging/logs_with_traces.py: Produce correlated logs inside an instrumented HTTP library's distributed tracing.

    Metrics Samples

    • metrics/attributes.py: Add attributes to custom metrics counters.
    • metrics/instruments.py: Create observable instruments.
    • metrics/live_metrics.py: Live metrics feature.

    Tracing Samples

    • tracing/azure_ai_inference.py: Instrument an app using Azure AI inference SDK.
    • tracing/azure_blob_storage.py: Instrument an app using Azure Blob storage SDK.
    • tracing/django/sample/manage.py: Instrument a Django app.
    • tracing/http_django_browser_sdk_loader.py: Instrument a Django app and inject Browser SDK snippet.
    • tracing/db_psycopg2.py: Instrument the Psycopg2 library.
    • tracing/http_fastapi.py: Instrument a FastAPI app.
    • tracing/http_flask.py: Instrument a Flask app.
    • tracing/http_httpx.py: Instrument the HTTPX library.
    • tracing/http_requests.py: Instrument the Requests library.
    • tracing/http_urllib.py: Instrument the URLLib library.
    • tracing/http_urllib3.py: Instrument the URLLib3 library.
    • tracing/instrumentation_options.py: Enable and disable instrumentations.
    • tracing/manually_instrumented.py: Manually add instrumentation.
    • tracing/modify_spans.py: Modify spans with span processors.
    • tracing/sampling.py: Sample distributed tracing telemetry.
    • tracing/tracing_simple.py: Produce manual spans.
  7. Overview of Azure Monitor Opentelemetry Distro for Python

    main

    The Azure Monitor Distro of OpenTelemetry Python is a telemetry solution designed to instrument applications with minimal code. It captures telemetry using OpenTelemetry instrumentations and reports it to Azure Monitor via Azure Monitor exporters.

    Key Features:

    • Requires only one line of code for instrumentation.
    • Automatically installs azure-monitor-opentelemetry-exporter and a subset of officially supported OpenTelemetry instrumentations.
    • Provides access to Azure Monitor OpenTelemetry exporter APIs.

    Note on Terminology: OpenTelemetry terminology differs from Application Insights terminology. It is recommended to understand how telemetry types map between the two before use.

  8. Understand Azure Attestation service operational modes

    main

    The Microsoft Azure Attestation (MAA) service operates in three modes. Choose the mode based on your requirements for instance management and authorization:

    • Shared Mode: No instance creation required. Provides a default attestation policy for SGX collateral. Limited to basic operations; cannot be used for TPM attestation which requires custom policies.
    • AAD Mode: Requires instance creation. Uses Azure ARM RBAC for authorization. Supports both signed and unsigned attestation policies.
    • Isolated Mode: Requires instance creation. Provides an additional layer of authorization beyond ARM RBAC. Requires an RSA asymmetric key pair and an X.509 certificate. Attestation policies MUST be signed with one of the private keys associated with the instance.
  9. Understand Azure AI Content Safety features and harm categories

    main

    The service provides several analysis capabilities and recognizes four distinct harm categories:

    Available APIs

    • Text Analysis API: Scans text for sexual content, violence, hate, and self-harm with multi-severity levels.
    • Image Analysis API: Scans images for sexual content, violence, hate, and self-harm with multi-severity levels.
    • Text Blocklist Management APIs: Allows creating and managing custom blocklists of terms to use with the Text API.

    Harm Categories

    • Hate: Content that attacks or uses pejorative/discriminatory language regarding identity groups (race, religion, gender, etc.).
    • Sexual: Language related to anatomical organs, romantic/erotic acts, or sexual violence.
    • Violence: Language related to physical actions intended to hurt, damage, or kill, including references to weapons.
    • Self-harm: Language related to physical actions intended to purposely hurt or kill oneself.