Microsoft.Extensions.Azure 1.5.0

.NET Standard 2.0
NuGet\Install-Package Microsoft.Extensions.Azure -Version 1.5.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package Microsoft.Extensions.Azure --version 1.5.0
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.Extensions.Azure --version 1.5.0
#r "nuget: Microsoft.Extensions.Azure, 1.5.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.Extensions.Azure as a Cake Addin
#addin nuget:?package=Microsoft.Extensions.Azure&version=1.5.0

// Install Microsoft.Extensions.Azure as a Cake Tool
#tool nuget:?package=Microsoft.Extensions.Azure&version=1.5.0

Azure client library integration for ASP.NET Core

Microsoft.Extensions.Azure provides shared primitives to integrate Azure clients with ASP.NET Core dependency injection and configuration systems.

Source code | Package (NuGet)

Getting started

Install the package

Install the ASP.NET Core integration library using NuGet:

dotnet add package Microsoft.Extensions.Azure

Register clients

Make a call to AddAzureClients in your app's ConfigureServices method. You can use the provided builder to register client instances with your dependency injection container.

public void ConfigureServices(IServiceCollection services)
    // Registering policy to use in ConfigureDefaults later

    services.AddAzureClients(builder => {
        // Register blob service client and initialize it using the KeyVault section of configuration
            // Set the name for this client registration
            // Set the credential for this client registration
            .WithCredential(new ClientSecretCredential("<tenant_id>", "<client_id>", "<client_secret>"))
            // Configure the client options
            .ConfigureOptions(options => options.Retry.MaxRetries = 10);

        // Adds a secret client using the provided endpoint and default credential set later
        builder.AddSecretClient(new Uri(""));

        // Configures environment credential to be used by default for all clients that require TokenCredential
        // and doesn't override it on per registration level
        builder.UseCredential(new EnvironmentCredential());

        // This would use configuration for auth and client settings

        // Configure global retry mode
        builder.ConfigureDefaults(options => options.Retry.Mode = RetryMode.Exponential);

        // Advanced configure global defaults
        builder.ConfigureDefaults((options, provider) =>  options.AddPolicy(provider.GetService<DependencyInjectionEnabledPolicy>(), HttpPipelinePosition.PerCall));

        // Register blob service client and initialize it using the Storage section of configuration

Inject clients

To use the client request the client type from any place that supports Dependency Injection (constructors, Configure calls, @inject razor definitions etc.)

public void Configure(IApplicationBuilder app, SecretClient secretClient, IAzureClientFactory<BlobServiceClient> blobClientFactory)

Create named instances

If client is registered as a named client inject IAzureClientFactory<T> and call CreateClient passing the name:

BlobServiceClient blobServiceClient = blobClientFactory.CreateClient("NamedBlobClient");

Configuration file used in the sample above:

  "Logging": {
    "LogLevel": {
      "Default": "Debug"
  "AllowedHosts": "*",
  "Default": {
    "ClientId": "<client_id>",
    "ClientSecret": "<client_secret>",
    "TenantId": "<tenant_id>",

    "TelemetryPolicy": {
      "ApplicationId": "AppId"
  "KeyVault": {
    "VaultUri": "<vault_uri>"
  "Storage": {
    "serviceUri": "<service_uri>",
    "credential": {
      "accountName": "<account_name>",
      "accountKey": "<account_key>"

Registering a custom client factory

If you want to take control over how the client instance is created or need to use other dependencies during the client construction use the AddClient<TClient, TOptions> method.

Here's and example of how to use IOptions<T> instance to construct the client:

public class MyApplicationOptions
    public Uri KeyVaultEndpoint { get; set; }

public void ConfigureServices(IServiceCollection services)
    // Configure a custom options instance
    services.Configure<MyApplicationOptions>(options => options.KeyVaultEndpoint = new Uri("http://localhost/"));

    services.AddAzureClients(builder =>
        // Register a client using MyApplicationOptions to get constructor parameters
        builder.AddClient<SecretClient, SecretClientOptions>((options, credential, provider) =>
            var appOptions = provider.GetService<IOptions<MyApplicationOptions>>();
            return new SecretClient(appOptions.Value.KeyVaultEndpoint, credential, options);


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

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 repos 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 with any additional questions or comments.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (23)

Showing the top 5 NuGet packages that depend on Microsoft.Extensions.Azure:

Package Downloads
Microsoft.Azure.WebJobs.Host.Storage The ID prefix of this package has been reserved for one of the owners of this package by

Package Description

Microsoft.Azure.WebJobs.Extensions.ServiceBus The ID prefix of this package has been reserved for one of the owners of this package by

Microsoft Azure WebJobs SDK ServiceBus Extension

Microsoft.Azure.WebJobs.Extensions.DurableTask The ID prefix of this package has been reserved for one of the owners of this package by

Azure WebJobs SDK Extension for the Durable Task Framework

Microsoft.Azure.WebJobs.Extensions.CosmosDB The ID prefix of this package has been reserved for one of the owners of this package by

This package contains binding extensions for Azure Cosmos DB.

Microsoft.Azure.WebJobs.Extensions.EventHubs The ID prefix of this package has been reserved for one of the owners of this package by

Microsoft Azure WebJobs SDK EventHubs Extension

GitHub repositories (9)

Showing the top 5 popular GitHub repositories that depend on Microsoft.Extensions.Azure:

Repository Stars
Documentation for ASP.NET Core
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 or our versioned developer docs at
The host/runtime that powers Azure Functions
Azure WebJobs SDK
Durable Task Framework extension for Azure Functions
Version Downloads Last updated
1.5.0 31,832 9/12/2022
1.4.0 147,082 8/12/2022
1.3.0 194,222 7/12/2022
1.2.0 1,408,041 5/10/2022
1.1.1 6,117,916 9/2/2021
1.1.0 963,184 6/9/2021
1.1.0-beta.3 5,389 5/11/2021
1.1.0-beta.2 259,267 2/8/2021
1.1.0-beta.1 54,697 11/6/2020
1.0.0 1,943,572 11/4/2019
1.0.0-preview.3 263 10/8/2019
1.0.0-preview.2 271 9/12/2019
1.0.0-preview.1 265 8/8/2019