You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 6-Deploy-to-Azure/README.md
+78-1
Original file line number
Diff line number
Diff line change
@@ -52,7 +52,84 @@ In the left-hand navigation pane, select the **Azure Active Directory** service,
52
52
53
53
Secure key management is essential to protect data in the cloud. Use [Azure Key Vault](https://azure.microsoft.com/en-ca/services/key-vault/) to encrypt keys and small secrets like passwords that use keys stored in hardware security modules (HSMs).
54
54
55
-
You can follow [this sample](https://github.com/Azure-Samples/app-service-msi-keyvault-dotnet) as a guide on how to use Azure KeyVault from App Service with Managed Service Identity (MSI).
55
+
Use [this sample](https://github.com/Azure-Samples/app-service-msi-keyvault-dotnet) as a guide on how to use Azure Key Vault from App Service with Managed Service Identity (MSI).
56
+
57
+
## MSAL token cache on distributed environments
58
+
59
+
The samples in this tutorial have their token cache providers configured for apps running on a single machine. On a production environment, these apps could be deployed in many machines for scalability purpose, so the token cache provider needs to be configured accordingly for this distributed architecture.
60
+
61
+
These are the necessary changes for each cache provider option:
62
+
63
+
### In memory
64
+
65
+
If you want to use in memory cache, use this configuration on `Startup.cs`:
66
+
67
+
```csharp
68
+
services.AddDistributedTokenCaches()
69
+
.AddDistributedMemoryCache();
70
+
```
71
+
72
+
### Redis
73
+
74
+
If you want to use a distributed Redis cache, use this configuration on `Startup.cs`:
-[configuring DataProtection for distributed environments](https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-2.2)
91
+
92
+
#### If you want to use .Net Core distributed cache extensions
93
+
94
+
Create the cache database by running the CLI (change the parameters according to your configurations)
95
+
96
+
```csharp
97
+
dotnetsql-cachecreate"<your DB connection string>"dbo<cacheTableName>
#### If you want to configure `DataProtection` for distributed environments
113
+
114
+
You have to configure the key ring storage to a centralized location. It could be in [Azure Key Vault](https://azure.microsoft.com/services/key-vault/) or on a [UNC share](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dfsc/149a3039-98ce-491a-9268-2f5ddef08192).
115
+
116
+
> **Note**: If you change the key persistence location, the system no longer automatically encrypts keys at rest. It is recommended that you use one of the ProtectKeysWith* methods listed [in this doc](https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-2.2).
117
+
118
+
For Azure Key Vault, configure the system with [PersistKeysToAzureBlobStorage](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.dataprotection.azuredataprotectionbuilderextensions.persistkeystoazureblobstorage?view=aspnetcore-2.2) (also consider using [ProtectKeysWithAzureKeyVault](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.dataprotection.azuredataprotectionbuilderextensions.protectkeyswithazurekeyvault)) in the `Startup` class:
119
+
120
+
```csharp
121
+
services.AddDataProtection()
122
+
.PersistKeysToAzureBlobStorage("<storage account connection or uri>");
123
+
```
124
+
125
+
> **Note**: Your app must have **Unwrap Key** and **Wrap Key** permissions to the Azure Key Vault.
126
+
127
+
For UNC share, configure the system with [PersistKeysToFileSystem](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.dataprotection.dataprotectionbuilderextensions.persistkeystofilesystem) (also consider using [ProtectKeysWithCertificate](https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.dataprotection.dataprotectionbuilderextensions.protectkeyswithcertificate?view=aspnetcore-2.2)) in the `Startup` class:
0 commit comments