Microsoft.Identity.Web.Azure
4.7.0
Prefix Reserved
dotnet add package Microsoft.Identity.Web.Azure --version 4.7.0
NuGet\Install-Package Microsoft.Identity.Web.Azure -Version 4.7.0
<PackageReference Include="Microsoft.Identity.Web.Azure" Version="4.7.0" />
<PackageVersion Include="Microsoft.Identity.Web.Azure" Version="4.7.0" />
<PackageReference Include="Microsoft.Identity.Web.Azure" />
paket add Microsoft.Identity.Web.Azure --version 4.7.0
#r "nuget: Microsoft.Identity.Web.Azure, 4.7.0"
#:package Microsoft.Identity.Web.Azure@4.7.0
#addin nuget:?package=Microsoft.Identity.Web.Azure&version=4.7.0
#tool nuget:?package=Microsoft.Identity.Web.Azure&version=4.7.0
Microsoft.Identity.Web.Azure
This package enables ASP.NET Core web apps and web APIs to use the Azure SDKs with the Microsoft identity platform (formerly Azure AD v2.0).
Features
- MicrosoftIdentityTokenCredential - Provides seamless integration between Microsoft.Identity.Web and Azure SDK's TokenCredential, enabling your application to use Azure services with Microsoft Entra ID (formerly Azure Active Directory) authentication.
- Supports both user delegated and application permission scenarios
- Works with the standard Azure SDK authentication flow
- Is Scoped (injected for each request, which means credendials can be different at each request.)
Installation
dotnet add package Microsoft.Identity.Web.Azure
## Usage
### Basic setup
1. Register the Azure Token Credential in your service collection:
```cshap
// In your Startup.cs or Program.cs
using Azure.Storage.Blobs;
using Microsoft.Extensions.Azure;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Web;
public void ConfigureServices(IServiceCollection services)
{
// Register Microsoft Identity Web
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebAppAuthentication(Configuration)
.EnableTokenAcquisitionToCallDownstreamApi();
services.AddInMemoryTokenCaches() // or others
// Add the Azure Token Credential
services.AddMicrosoftIdentityAzureTokenCredential();
}
Using with Azure SDK clients
Once registered, the MicrosoftIdentityAzureTokenCredential can be injected directly into your controllers or services: // Direct injection into a controller or Razor Page
[Authorize]
public class BlobController : Controller
{
private readonly MicrosoftIdentityTokenCredential _tokenCredential;
public BlobController(
MicrosoftIdentityTokenCredential tokenCredential)
{
_tokenCredential = tokenCredential;
}
[HttpGet]
public async Task<IActionResult> DownloadBlob(string containerName, string blobName)
{
try
{
// If you want to have get a blob on behalf of the app itself.
_tokenCredential.Options.RequestAppToken = true;
BlobContainerClient containerClient = new BlobContainerClient(new Uri($"https://storageaccountname.blob.core.windows.net/{containername}"), _microsoftIdentityTokenCredential);
var blobClient = containerClient.GetBlobClient(blobName);
// Check if blob exists
if (!await blobClient.ExistsAsync())
{
return NotFound($"Blob '{blobName}' not found in container '{containerName}'");
}
// Download the blob content
var response = await blobClient.DownloadContentAsync();
string content = response.Value.Content.ToString();
return Content(content);
}
catch (Exception ex)
{
return StatusCode(500, $"Error accessing blob: {ex.Message}");
}
}
For Razor Pages, you can similarly inject the client directly:
public class BlobModel : PageModel
{
private readonly MicrosoftIdentityTokenCredential _tokenCredential;
public BlobModel(MicrosoftIdentityTokenCredential tokenCredential)
{
_tokenCredential = tokenCredential;
}
public async Task<IActionResult> OnGetAsync(string containerName, string blobName)
{
BlobContainerClient containerClient = new BlobContainerClient(new Uri($"https://storageaccountname.blob.core.windows.net/{containername}"), _microsoftIdentityTokenCredential);
// ...rest of the implementation
}
}
How does this differ
The Azure SDK guidance proposes to set Azure clients as singletons at stardup (so likely app only credentials). MicrosoftIdentityTokenCredential enables you to have one credential at each request, with user context, tenant, long running process, and all the flexibility that Microsoft.Identity.Web bring.
// Register Azure services
services.AddAzureClients(builder =>
{
// Use the Microsoft Identity credential for all Azure clients
builder.UseCredential(sp => sp.GetRequiredService<TokenCredential>());
// Configure Azure Blob Storage client
builder.AddBlobServiceClient(new Uri("https://your-storage-account.blob.core.windows.net"));
// Add other Azure clients as needed
});
Advanced scenarios
Using with specific authentication schemes
If your application has multiple authentication schemes, you can specify which one to use: // Configure the token credential to use a specific authentication scheme tokenCredential.Options.AcquireTokenOptions.AuthenticationOptionsName = OpenIdConnectDefaults.AuthenticationScheme;
Custom configuration
You can customize the token acquisition behavior:
// Configure additional options
tokenCredential.Options.AcquireTokenOptions.CorrelationId = Guid.NewGuid();
tokenCredential.Options.AcquireTokenOptions.Tenant = "GUID";
## Credential Status (v4)
| Credential | Status | Guidance |
|------------|--------|----------|
| `MicrosoftIdentityTokenCredential` | Recommended | Unified credential for user, app, and agent scenarios. Configure via `Options` (e.g., `RequestAppToken`, `WithAgentIdentity`). |
| `TokenAcquirerTokenCredential` | Obsolete | Replace with `MicrosoftIdentityTokenCredential`. See [migration guide](https://aka.ms/ms-id-web/v3-to-v4). |
| `TokenAcquirerAppTokenCredential` | Obsolete | Replace with `MicrosoftIdentityTokenCredential` (`Options.RequestAppToken = true`). See [migration guide](https://aka.ms/ms-id-web/v3-to-v4). |
## Integration with Azure SDKs
This package enables integration with [Azure SDKs for .NET](https://learn.microsoft.com/dotnet/azure/sdk/azure-sdk-for-dotnet), including but not limited to:
- Azure Storage (Blobs, Queues, Tables, Files)
- Azure Key Vault (although you might rather want to use the DefaultCrentialLoader for credentials)
- Azure Service Bus
- Azure Cosmos DB
- Azure Event Hubs
- Azure Monitor
See [Azure SDK for .NET packages](https://learn.microsoft.com/dotnet/azure/sdk/packages#libraries-using-azurecore)
for the list of packages.
## Related packages
- [Microsoft.Identity.Web](https://www.nuget.org/packages/Microsoft.Identity.Web/)
- [Microsoft.Identity.Web.UI](https://www.nuget.org/packages/Microsoft.Identity.Web.UI/)
- [Microsoft.Identity.Web.MicrosoftGraph](https://www.nuget.org/packages/Microsoft.Identity.Web.MicrosoftGraph/)
## Learn more
- [Microsoft Identity Web documentation](https://aka.ms/ms-identity-web)
- [Azure SDK documentation](https://docs.microsoft.com/azure/developer/azure-sdk/)
- [Microsoft identity platform documentation](https://docs.microsoft.com/azure/active-directory/develop/)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Identity.Web.TokenAcquisition (>= 4.7.0)
-
.NETFramework 4.7.2
- Microsoft.Identity.Web.TokenAcquisition (>= 4.7.0)
-
.NETStandard 2.0
- Microsoft.Identity.Web.TokenAcquisition (>= 4.7.0)
-
net10.0
- Microsoft.Identity.Web.TokenAcquisition (>= 4.7.0)
-
net8.0
- Microsoft.Identity.Web.TokenAcquisition (>= 4.7.0)
-
net9.0
- Microsoft.Identity.Web.TokenAcquisition (>= 4.7.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.7.0 | 276 | 4/2/2026 |
| 4.6.0 | 939 | 3/20/2026 |
| 4.5.0 | 1,208 | 3/5/2026 |
| 4.4.0 | 14,968 | 2/27/2026 |
| 4.4.0-preview.1 | 4,148 | 2/13/2026 |
| 4.3.0 | 23,798 | 1/7/2026 |
| 4.2.0 | 16,260 | 12/17/2025 |
| 4.1.1 | 5,489 | 11/24/2025 |
| 4.1.0 | 3,438 | 11/19/2025 |
| 4.0.1 | 42,576 | 10/20/2025 |
| 4.0.0 | 5,468 | 10/13/2025 |
| 3.14.1 | 20,327 | 9/10/2025 |
| 3.14.0 | 8,194 | 8/28/2025 |
| 3.13.2 | 5,926 | 8/19/2025 |
| 3.13.1 | 5,247 | 8/15/2025 |
| 3.13.0 | 9,460 | 8/8/2025 |
| 3.12.0 | 4,758 | 7/30/2025 |
| 3.11.0 | 5,139 | 7/21/2025 |
| 3.10.0 | 5,114 | 7/5/2025 |
| 3.9.4 | 4,929 | 6/17/2025 |
The release notes are available at https://github.com/AzureAD/microsoft-identity-web/releases and the roadmap at https://github.com/AzureAD/microsoft-identity-web/wiki#roadmap