Convert Figma logo to code with AI

Azure logoazure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.

4,532
2,757
4,532
1,023

Top Related Projects

Microsoft Azure PowerShell

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:

Quick Overview

The Azure/azure-sdk-for-python repository is the official Python SDK for interacting with Microsoft Azure services. It provides a comprehensive set of libraries and tools for developers to build applications that leverage the power of the Azure cloud platform.

Pros

  • Comprehensive Coverage: The SDK covers a wide range of Azure services, including compute, storage, networking, databases, and more, allowing developers to easily integrate Azure functionality into their applications.
  • Ease of Use: The SDK is designed to be user-friendly, with clear documentation and examples, making it easier for developers to get started and be productive.
  • Cross-Platform Compatibility: The SDK is compatible with multiple Python versions and can be used on various operating systems, including Windows, macOS, and Linux.
  • Active Development and Support: The SDK is actively maintained by Microsoft, with regular updates and bug fixes, ensuring that developers have access to the latest features and improvements.

Cons

  • Complexity: With the wide range of services and features covered by the SDK, the learning curve can be steep, especially for developers new to Azure.
  • Performance Overhead: Depending on the specific use case, the SDK may introduce some performance overhead due to the abstraction layer it provides.
  • Dependency on Azure Services: The SDK is tightly integrated with Azure services, which means that developers may be locked into the Azure ecosystem if they choose to use this SDK.
  • Limited Third-Party Integration: While the SDK provides extensive support for Azure services, it may have limited integration with third-party tools and libraries, which could be a drawback for some developers.

Code Examples

Here are a few code examples demonstrating the usage of the Azure SDK for Python:

  1. Authenticating with Azure:
from azure.identity import DefaultAzureCredential

credential = DefaultAzureCredential()
  1. Interacting with Azure Storage:
from azure.storage.blob import BlobServiceClient

blob_service_client = BlobServiceClient.from_connection_string("your_connection_string")
container_client = blob_service_client.get_container_client("my-container")
blob_client = container_client.get_blob_client("my-blob.txt")
blob_client.upload_blob("Hello, Azure!")
  1. Deploying an Azure Function:
from azure.functions import func

@func.api_key_required
def main(req: func.HttpRequest) -> func.HttpResponse:
    name = req.params.get('name')
    if name:
        return func.HttpResponse(f"Hello, {name}!")
    else:
        return func.HttpResponse("Please pass a name in the query string or in the request body", status_code=400)
  1. Interacting with Azure Cosmos DB:
from azure.cosmos import CosmosClient

client = CosmosClient(url="your_cosmos_db_endpoint", credential="your_cosmos_db_key")
database = client.get_database_client("my-database")
container = database.get_container_client("my-container")
item = container.create_item({"id": "1", "name": "John Doe"})

Getting Started

To get started with the Azure SDK for Python, follow these steps:

  1. Install the SDK using pip:
pip install azure-identity azure-storage-blob azure-functions azure-cosmos
  1. Import the necessary modules and initialize the required clients:
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient
from azure.functions import func
from azure.cosmos import CosmosClient
  1. Authenticate with Azure using the DefaultAzureCredential class, which automatically retrieves the necessary credentials from your environment.

  2. Interact with Azure services, such as Blob Storage, Azure Functions, and Cosmos DB, using the respective client objects.

  3. Refer to the Azure SDK for Python documentation for more detailed information and examples on how to use the various Azure services.

Competitor Comparisons

Microsoft Azure PowerShell

Pros of Azure/azure-powershell

  • Provides a familiar PowerShell-based interface for managing Azure resources, which may be preferred by administrators and DevOps teams already familiar with PowerShell.
  • Offers a comprehensive set of cmdlets for managing a wide range of Azure services, including virtual machines, storage, networking, and more.
  • Supports scripting and automation, allowing for the creation of complex Azure deployment and management workflows.

Cons of Azure/azure-powershell

  • Requires the installation of the Azure PowerShell module, which may not be suitable for all development environments or platforms.
  • May have a steeper learning curve for developers who are more comfortable with Python or other programming languages.
  • Potentially less flexible and extensible than the Azure SDK for Python, which can be more easily integrated into custom applications and scripts.

Code Comparison

Azure/azure-sdk-for-python (Python):

from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import ResourceManagementClient

credential = DefaultAzureCredential()
resource_client = ResourceManagementClient(credential, subscription_id)

# List resource groups
resource_groups = resource_client.resource_groups.list()
for rg in resource_groups:
    print(rg.name)

Azure/azure-powershell (PowerShell):

Connect-AzAccount
Get-AzResourceGroup | Select-Object Name

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.

Pros of Azure/azure-sdk-for-java

  • Comprehensive coverage of Azure services, with support for a wide range of features and functionality.
  • Strong community support and active development, with frequent updates and improvements.
  • Robust error handling and exception management, making it easier to build reliable applications.

Cons of Azure/azure-sdk-for-java

  • Larger codebase and more complex API, which can make it more challenging for beginners to get started.
  • Potentially slower performance compared to the Python SDK, due to the inherent overhead of the Java language.
  • Dependency on the Java ecosystem, which may not be preferred by developers working in other programming languages.

Code Comparison

Azure/azure-sdk-for-python:

from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import ResourceManagementClient

credential = DefaultAzureCredential()
resource_client = ResourceManagementClient(credential, subscription_id)

# List resource groups
resource_groups = resource_client.resource_groups.list()
for resource_group in resource_groups:
    print(resource_group.name)

Azure/azure-sdk-for-java:

import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.resourcemanager.AzureResourceManager;
import com.azure.resourcemanager.resources.models.ResourceGroup;

AzureResourceManager azureResourceManager = AzureResourceManager.configure()
    .withLogLevel(HttpLogDetailLevel.BASIC)
    .authenticate(new DefaultAzureCredentialBuilder().build())
    .withSubscription(subscriptionId);

// List resource groups
for (ResourceGroup resourceGroup : azureResourceManager.resourceGroups().list()) {
    System.out.println(resourceGroup.name());
}

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.

Pros of Azure/azure-sdk-for-js

  • Consistent API Design: The Azure SDK for JavaScript follows a consistent API design across all services, making it easier for developers to work with multiple Azure services.
  • Asynchronous Operations: The JavaScript SDK provides a more natural asynchronous programming model, leveraging Promises and async/await syntax.
  • Broader Platform Support: The JavaScript SDK can be used in both browser and Node.js environments, providing more flexibility for developers.

Cons of Azure/azure-sdk-for-js

  • Dependency on TypeScript: The JavaScript SDK is primarily written in TypeScript, which may be a barrier for developers who are more comfortable with plain JavaScript.
  • Potential Performance Overhead: The use of Promises and async/await in the JavaScript SDK may introduce some performance overhead compared to more low-level, synchronous approaches.
  • Fewer Services Covered: The JavaScript SDK currently covers a smaller subset of Azure services compared to the Python SDK.

Code Comparison

Azure/azure-sdk-for-python:

from azure.storage.blob import BlobServiceClient

blob_service_client = BlobServiceClient.from_connection_string("connection_string")
container_client = blob_service_client.get_container_client("my-container")
blob_client = container_client.get_blob_client("my-blob.txt")
blob_client.upload_blob("Hello, Azure Blob Storage!")

Azure/azure-sdk-for-js:

const { BlobServiceClient } = require("@azure/storage-blob");

const blobServiceClient = BlobServiceClient.fromConnectionString("connection_string");
const containerClient = blobServiceClient.getContainerClient("my-container");
const blobClient = containerClient.getBlobClient("my-blob.txt");
await blobClient.upload("Hello, Azure Blob Storage!");

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.

Pros of Azure/azure-sdk-for-net

  • Tight integration with the .NET ecosystem, including seamless Visual Studio integration and support for popular .NET patterns and libraries.
  • Comprehensive coverage of Azure services, with SDKs for a wide range of Azure offerings.
  • Strong type safety and compile-time validation, which can help catch errors early in the development process.

Cons of Azure/azure-sdk-for-net

  • Limited cross-platform support, as the .NET SDK is primarily designed for Windows-based environments.
  • Potentially higher learning curve for developers not familiar with the .NET ecosystem.
  • Potential performance overhead compared to more lightweight, cross-platform alternatives.

Code Comparison

Azure/azure-sdk-for-python:

from azure.storage.blob import BlobServiceClient

blob_service_client = BlobServiceClient.from_connection_string("connection_string")
container_client = blob_service_client.get_container_client("container_name")
blob_client = container_client.get_blob_client("blob_name")
blob_client.upload_blob("Hello, Azure Blob Storage!")

Azure/azure-sdk-for-net:

using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;

BlobServiceClient blobServiceClient = new BlobServiceClient("connection_string");
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("container_name");
BlobClient blobClient = containerClient.GetBlobClient("blob_name");
await blobClient.UploadAsync("Hello, Azure Blob Storage!");

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:

Pros of Azure/azure-sdk-for-go

  • Concurrency: Go's built-in support for concurrency and goroutines can make the Azure SDK for Go more efficient and scalable for certain use cases.
  • Performance: Go is generally known for its performance, which can be beneficial for applications that require high-throughput or low-latency interactions with Azure services.
  • Simplicity: The Go programming language is often praised for its simplicity and ease of use, which can make the Azure SDK for Go more approachable for some developers.

Cons of Azure/azure-sdk-for-go

  • Ecosystem: The Python ecosystem is generally larger and more mature, with a wider range of libraries and tools available for working with Azure services.
  • Familiarity: Python is a more widely-used language, especially in the cloud and data-centric domains, which means more developers may be familiar with the Azure SDK for Python.
  • Documentation: The Azure SDK for Python may have more comprehensive and user-friendly documentation compared to the Azure SDK for Go.

Code Comparison

Azure SDK for Python:

from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import ResourceManagementClient

credential = DefaultAzureCredential()
resource_client = ResourceManagementClient(credential, subscription_id)

# List resource groups
resource_groups = resource_client.resource_groups.list()
for resource_group in resource_groups:
    print(resource_group.name)

Azure SDK for Go:

import (
    "context"
    "fmt"
    "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-05-01/resources"
    "github.com/Azure/go-autorest/autorest/azure/auth"
)

func main() {
    authorizer, err := auth.NewAuthorizerFromEnvironment()
    if err != nil {
        // Handle error
    }

    client := resources.NewGroupsClient(subscriptionID)
    client.Authorizer = authorizer

    result, err := client.List(context.Background(), nil)
    if err != nil {
        // Handle error
    }

    for _, rg := range result.Values() {
        fmt.Println(*rg.Name)
    }
}

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Azure SDK for Python

Packages Dependencies DepGraph Python Build Status

This repository is for the active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs or our versioned developer docs.

Disclaimer

Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691

Getting started

For your convenience, each service has a separate set of libraries that you can choose to use instead of one, large Azure package. To get started with a specific library, see the README.md (or README.rst) file located in the library's project folder.

You can find service libraries in the /sdk directory.

Prerequisites

The client libraries are supported on Python 3.8 or later. For more details, please read our page on Azure SDK for Python version support policy.

Packages available

Each service might have a number of libraries available from each of the following categories:

Client: New Releases

New wave of packages that we are announcing as GA and several that are currently releasing in preview. These libraries allow you to use and consume existing resources and interact with them, for example: upload a blob. These libraries share several core functionalities such as: retries, logging, transport protocols, authentication protocols, etc. that can be found in the azure-core library. You can learn more about these libraries by reading guidelines that they follow here.

You can find the most up to date list of all of the new packages on our page

NOTE: If you need to ensure your code is ready for production use one of the stable, non-preview libraries.

Client: Previous Versions

Last stable versions of packages that have been provided for usage with Azure and are production-ready. These libraries provide you with similar functionalities to the Preview ones as they allow you to use and consume existing resources and interact with them, for example: upload a blob. They might not implement the guidelines or have the same feature set as the November releases. They do however offer wider coverage of services.

Management: New Releases

A new set of management libraries that follow the Azure SDK Design Guidelines for Python are now available. These new libraries provide a number of core capabilities that are shared amongst all Azure SDKs, including the intuitive Azure Identity library, an HTTP Pipeline with custom policies, error-handling, distributed tracing, and much more. Documentation and code samples for these new libraries can be found here. In addition, a migration guide that shows how to transition from older versions of libraries is located here.

You can find the most up to date list of all of the new packages on our page

NOTE: If you need to ensure your code is ready for production use one of the stable, non-preview libraries. Also, if you are experiencing authentication issues with the management libraries after upgrading certain packages, it's possible that you upgraded to the new versions of SDK without changing the authentication code, please refer to the migration guide mentioned above for proper instructions.

Management: Previous Versions

For a complete list of management libraries that enable you to provision and manage Azure resources, please check here. They might not have the same feature set as the new releases but they do offer wider coverage of services. Management libraries can be identified by namespaces that start with azure-mgmt-, e.g. azure-mgmt-compute

Need help?

Reporting security issues and security bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

Contributing

For details on contributing to this repository, see the contributing guide.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Impressions