Skip to content

Commit 931e5fd

Browse files
committed
Updates
1 parent 1ed2cf8 commit 931e5fd

File tree

6 files changed

+46
-42
lines changed

6 files changed

+46
-42
lines changed

aspnetcore/blazor/call-web-api.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to call a web API from Blazor apps.
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: wpickett
77
ms.custom: mvc
8-
ms.date: 06/06/2025
8+
ms.date: 06/09/2025
99
uid: blazor/call-web-api
1010
---
1111
# Call a web API from ASP.NET Core Blazor
@@ -138,7 +138,7 @@ Use a shared Data Protection key ring in production so that instances of the app
138138
>
139139
> Later in the development and testing period, enable token encryption and adopt a shared Data Protection key ring.
140140
141-
The following example shows how to use [Azure Blob Storage and Azure Key Vault (`PersistKeysToAzureBlobStorage`/`ProtectKeysWithAzureKeyVault`)](xref:security/data-protection/configuration/overview#protect-keys-with-azure-key-vault-protectkeyswithazurekeyvault) for the shared key ring. The service configurations are base case scenarios for demonstration purposes. Before deploying production apps, familiarize yourself with the Azure services and adopt best practices using their dedicated documentation sets, which are listed at the end of this section.
141+
The following example shows how to use [Azure Blob Storage and Azure Key Vault (`PersistKeysToAzureBlobStorage`/`ProtectKeysWithAzureKeyVault`)](xref:security/data-protection/configuration/overview#protect-keys-with-azure-key-vault-protectkeyswithazurekeyvault) for the shared key ring. The service configurations are base case scenarios for demonstration purposes. Before deploying production apps, familiarize yourself with the Azure services and adopt best practices using the Azure services' dedicated documentation sets, which are cross-linked at the end of this section.
142142
143143
Add the following packages to the server project of the Blazor Web App:
144144
@@ -175,7 +175,7 @@ builder.Services.AddDataProtection()
175175
.PersistKeysToAzureBlobStorage(new Uri("{BLOB URI}"), credential)
176176
.ProtectKeysWithAzureKeyVault(new Uri("{KEY IDENTIFIER}"), credential);
177177
178-
/* Blob URI with SAS approach
178+
/* Alternative without using an Azure Managed Identity: SAS approach
179179
builder.Services.AddDataProtection()
180180
.SetApplicationName("BlazorWebAppEntra")
181181
.PersistKeysToAzureBlobStorage(new Uri("{BLOB URI WITH SAS}"))
@@ -187,7 +187,7 @@ builder.Services.AddDataProtection()
187187
188188
`{BLOB URI}`: Full URI to the key file. The URI is generated by Azure Storage when you create the key file. Do not use a SAS.
189189
190-
`{BLOB URI WITH SAS}`: The full URI where the key file should be stored with the SAS token as a query string parameter. The URI is generated by Azure Storage when you request a SAS for the uploaded key file.
190+
`{BLOB URI WITH SAS}`: *This approach only applies if you opt not to use an Azure Managed Identity.* The full URI where the key file should be stored with the SAS token as a query string parameter. The URI is generated by Azure Storage when you request a SAS for the uploaded key file.
191191
192192
`{KEY IDENTIFIER}`: Azure Key Vault key identifier used for key encryption. An access policy allows the application to access the key vault with `Get`, `Unwrap Key`, and `Wrap Key` permissions. The key identifier is obtained from the key in the Entra or Azure portal after it's created. If you enable autorotation of the key vault key, make sure that you use a versionless key identifier in the app's key vault configuration, where no key GUID is placed at the end of the identifier (example: `https://contoso.vault.azure.net/keys/data-protection`).
193193
@@ -229,6 +229,7 @@ For more information, see the following resources:
229229
* [Host ASP.NET Core in a web farm: Data Protection](xref:host-and-deploy/web-farm#data-protection)
230230
* [Azure Key Vault documentation](/azure/key-vault/general/)
231231
* [Azure Storage documentation](/azure/storage/)
232+
* [Provide access to Key Vault keys, certificates, and secrets with Azure role-based access control](/azure/key-vault/general/rbac-guide?tabs=azure-cli)
232233
233234
## Sample apps
234235

aspnetcore/blazor/security/blazor-web-app-with-entra.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to secure a Blazor Web App with Microsoft Entra ID.
55
monikerRange: '>= aspnetcore-9.0'
66
ms.author: wpickett
77
ms.custom: mvc
8-
ms.date: 06/06/2025
8+
ms.date: 06/09/2025
99
uid: blazor/security/blazor-web-app-entra
1010
zone_pivot_groups: blazor-web-app-entra-specification
1111
---
@@ -763,7 +763,7 @@ Use a shared Data Protection key ring in production so that instances of the app
763763
>
764764
> Later in the development and testing period, enable token encryption and adopt a shared Data Protection key ring.
765765
766-
The following example shows how to use [Azure Blob Storage and Azure Key Vault (`PersistKeysToAzureBlobStorage`/`ProtectKeysWithAzureKeyVault`)](xref:security/data-protection/configuration/overview#protect-keys-with-azure-key-vault-protectkeyswithazurekeyvault) for the shared key ring. The service configurations are base case scenarios for demonstration purposes. Before deploying production apps, familiarize yourself with the Azure services and adopt best practices using their dedicated documentation sets, which are listed at the end of this section.
766+
The following example shows how to use [Azure Blob Storage and Azure Key Vault (`PersistKeysToAzureBlobStorage`/`ProtectKeysWithAzureKeyVault`)](xref:security/data-protection/configuration/overview#protect-keys-with-azure-key-vault-protectkeyswithazurekeyvault) for the shared key ring. The service configurations are base case scenarios for demonstration purposes. Before deploying production apps, familiarize yourself with the Azure services and adopt best practices using the Azure services' dedicated documentation sets, which are cross-linked at the end of this section.
767767
768768
Confirm the presence of the following packages in the server project of the Blazor Web App:
769769
@@ -799,12 +799,8 @@ else
799799
800800
builder.Services.AddDataProtection()
801801
.SetApplicationName("BlazorWebAppEntra")
802-
.PersistKeysToAzureBlobStorage(
803-
new Uri("{BLOB URI}"),
804-
credential)
805-
.ProtectKeysWithAzureKeyVault(
806-
new Uri("{KEY IDENTIFIER}"),
807-
credential);
802+
.PersistKeysToAzureBlobStorage(new Uri("{BLOB URI}"), credential)
803+
.ProtectKeysWithAzureKeyVault(new Uri("{KEY IDENTIFIER}"), credential);
808804
809805
/* Blob URI with SAS approach
810806
builder.Services.AddDataProtection()
@@ -818,12 +814,12 @@ builder.Services.AddDataProtection()
818814

819815
`{BLOB URI}`: Full URI to the key file. The URI is generated by Azure Storage when you create the key file. Do not use a SAS.
820816

821-
`{BLOB URI WITH SAS}`: The full URI where the key file should be stored with the SAS token as a query string parameter. The URI is generated by Azure Storage when you request a SAS for the uploaded key file.
817+
`{BLOB URI WITH SAS}`: *This approach only applies if you opt not to use an Azure Managed Identity.* The full URI where the key file should be stored with the SAS token as a query string parameter. The URI is generated by Azure Storage when you request a SAS for the uploaded key file.
822818

823819
`{KEY IDENTIFIER}`: Azure Key Vault key identifier used for key encryption. An access policy allows the application to access the key vault with `Get`, `Unwrap Key`, and `Wrap Key` permissions. The version of the key is obtained from the key in the Entra or Azure portal after it's created. If you enable autorotation of the key vault key, make sure that you use a versionless key identifier in the app's key vault configuration, where no key GUID is placed at the end of the identifier (example: `https://contoso.vault.azure.net/keys/data-protection`).
824820

825821
> [!NOTE]
826-
> The preceding example uses <xref:Azure.Identity.DefaultAzureCredential> locally (non-Production environment) to simplify authentication while developing apps that deploy to Azure by combining credentials used in Azure hosting environments with credentials used in local development. When moving to production, an alternative is a better choice, such as the <xref:Azure.Identity.ManagedIdentityCredential> shown in the preceding example. For more information, see [Authenticate Azure-hosted .NET apps to Azure resources using a system-assigned managed identity](/dotnet/azure/sdk/authentication/system-assigned-managed-identity).
822+
> The preceding example uses <xref:Azure.Identity.DefaultAzureCredential> locally (non-Production environment) to simplify authentication while developing apps that deploy to Azure by combining credentials used in Azure hosting environments with credentials used in local development. For more information, see [Authenticate Azure-hosted .NET apps to Azure resources using a system-assigned managed identity](/dotnet/azure/sdk/authentication/system-assigned-managed-identity).
827823
828824
Alternatively, you can configure the app to supply the values from app settings files using the JSON Configuration Provider. Add the following to the app settings file:
829825

@@ -845,10 +841,13 @@ Example `DataProtection` section:
845841
```json
846842
"DataProtection": {
847843
"BlobUri": "https://contoso.blob.core.windows.net/data-protection/keys.xml",
848-
"KeyIdentifier": "https://contoso.vault.azure.net/keys/data-protection/11112222bbbb3333cccc4444dddd5555"
844+
"KeyIdentifier": "https://contoso.vault.azure.net/keys/data-protection"
849845
}
850846
```
851847

848+
> [!NOTE]
849+
> The key identifier in the preceding example is *versionless*. There's no GUID key version on the end of the identifier. This is particularly important if you opt to configure automatic key rotation for the key. For more information, see [Configure cryptographic key auto-rotation in Azure Key Vault: Key rotation policy](/azure/key-vault/keys/how-to-configure-key-rotation#key-rotation-policy).
850+
852851
Make the following changes in the `Program` file:
853852

854853
```diff
@@ -873,12 +872,8 @@ builder.Services.Configure<MsalDistributedTokenCacheAdapterOptions>(
873872

874873
- builder.Services.AddDataProtection()
875874
- .SetApplicationName("BlazorWebAppEntra")
876-
- .PersistKeysToAzureBlobStorage(
877-
- new Uri("{BLOB URI}"),
878-
- credential)
879-
- .ProtectKeysWithAzureKeyVault(
880-
- new Uri("{KEY IDENTIFIER}"),
881-
- credential);
875+
- .PersistKeysToAzureBlobStorage(new Uri("{BLOB URI}"), credential)
876+
- .ProtectKeysWithAzureKeyVault(new Uri("{KEY IDENTIFIER}"), credential);
882877
```
883878

884879
Add the following code where services are configured in the `Program` file:
@@ -908,6 +903,7 @@ For more information on using a shared Data Protection key ring and key storage
908903
* <xref:security/data-protection/implementation/key-storage-providers>
909904
* [Azure Key Vault documentation](/azure/key-vault/general/)
910905
* [Azure Storage documentation](/azure/storage/)
906+
* [Provide access to Key Vault keys, certificates, and secrets with Azure role-based access control](/azure/key-vault/general/rbac-guide?tabs=azure-cli)
911907

912908
## Redirect to the home page on logout
913909

aspnetcore/release-notes/aspnetcore-9/includes/delete_keys.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
Prior to .NET 9, data protection keys were ___not___ deletable by design, to prevent data loss. Deleting a key renders its protected data irretrievable. Given their small size, the accumulation of these keys generally posed minimal impact. However, to accommodate extremely long-running services, we have introduced the option to delete keys. Generally, only old keys should be deleted. Only delete keys when you can accept the risk of data loss in exchange for storage savings. We recommend data protection keys should ___not___ be deleted.
44

5-
:::code language="csharp" source="~/security/data-protection/configuration/samples/9.x/deleteKeys/Program.cs" :::
5+
:::code language="csharp" source="~/security/data-protection/configuration/samples/9.x/deleteKeys/Program.cs":::

aspnetcore/security/data-protection/configuration/default-settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Deleting a key makes its protected data permanently inaccessible. To mitigate th
5858

5959
We recommend not deleting data protection keys.
6060

61-
:::code language="csharp" source="~/security/data-protection/configuration/samples/9.x/deleteKeys/Program.cs" :::
61+
:::code language="csharp" source="~/security/data-protection/configuration/samples/9.x/deleteKeys/Program.cs":::
6262

6363
## Additional resources
6464

0 commit comments

Comments
 (0)