AspNetCore.Identity.Stores.AzureCosmosDB
1.0.2
See the version list below for details.
dotnet add package AspNetCore.Identity.Stores.AzureCosmosDB --version 1.0.2
NuGet\Install-Package AspNetCore.Identity.Stores.AzureCosmosDB -Version 1.0.2
<PackageReference Include="AspNetCore.Identity.Stores.AzureCosmosDB" Version="1.0.2" />
paket add AspNetCore.Identity.Stores.AzureCosmosDB --version 1.0.2
#r "nuget: AspNetCore.Identity.Stores.AzureCosmosDB, 1.0.2"
// Install AspNetCore.Identity.Stores.AzureCosmosDB as a Cake Addin #addin nuget:?package=AspNetCore.Identity.Stores.AzureCosmosDB&version=1.0.2 // Install AspNetCore.Identity.Stores.AzureCosmosDB as a Cake Tool #tool nuget:?package=AspNetCore.Identity.Stores.AzureCosmosDB&version=1.0.2
Azure Cosmos DB
This is how to use Azure Cosmos DB as storage for ASP.NET identity.
Create a new ASP.NET Core Web App
From Additional information dialog select authentication type Individual Accounts
Install AspNetCore.Identity.Stores.AzureCosmosDB package from NuGet manager
In Startup.cs replace the code inside ConfigureServices method with the folowing code
using AspNetCore.Identity.Stores; using AspNetCore.Identity.Stores.AzureCosmosDB.Extensions;
//Adds data protection services, needed to protect the identity personal data services.AddDataProtection(); //Configure identity repository connection services.Configure<IdentityStoresOptions>(options => options .UseAzureCosmosDB(Configuration.GetConnectionString("DefaultConnection"), "MyDatabase")); services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddRoles<IdentityRole>() .AddAzureCosmosDbStores(); //Add Identity stores services.AddRazorPages();
In appsettings.json update DefaultConnection with Azure Cosmos DB connection string.
Configuration
As shown in the code snippet from point 4, IdentityStoresOptions has an extension method UseAzureCosmosDB to configure the connection and it has 3 parameters:
- connectionString: To specify the connection string of CosmosDB instance.
- databaseId: To specify the database which will be used.
- containerId (optinal): To specify the container which will be used, the default value is AspNetIdentity
Note: If the specified database or container not exist, they will get created on startup.
See more:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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 was computed. 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. |
-
net5.0
- AspNetCore.Identity.Stores (>= 1.0.2)
- Microsoft.AspNetCore.DataProtection.Abstractions (>= 5.0.8)
- Microsoft.Azure.Cosmos (>= 3.20.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.