Skip to content

Commit 1130216

Browse files
authored
Merge pull request #8899 from MicrosoftDocs/main
Auto push to live 2025-05-09 10:01:57
2 parents 42afd1e + eebe9d3 commit 1130216

15 files changed

+630
-267
lines changed

.openpublishing.redirection.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13684,6 +13684,10 @@
1368413684
"source_path": "support/windows-server/active-directory/dcs-cannot-be-located-high-rate-outbound-sessions.md",
1368513685
"redirect_url": "/troubleshoot/windows-server/user-profiles-and-logon/dcs-cannot-be-located-high-rate-outbound-sessions"
1368613686
},
13687+
{
13688+
"source_path": "support/windows-server/active-directory/troubleshoot-errors-join-computer-to-domain.md",
13689+
"redirect_url": "/troubleshoot/windows-server/active-directory/networking-errors-join-computer-domain"
13690+
},
1368713691
{
1368813692
"source_path": "support/power-platform/power-automate/desktop-flows/troubleshoot-excel-errors.md",
1368913693
"redirect_url": "/troubleshoot/power-platform/power-automate/desktop-flows/office-automation/excel/troubleshoot-excel-errors"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: OrasPullNetworkTimeoutVMExtensionError When Creating AKS Clusters
3+
description: Learn how to troubleshoot the OrasPullNetworkTimeoutVMExtensionError error (211) when you try to create and deploy an Azure Kubernetes Service (AKS) cluster.
4+
ms.date: 05/09/2025
5+
ms.reviewer: xinhl, v-weizhu
6+
ms.service: azure-kubernetes-service
7+
#Customer intent: As an Azure Kubernetes user, I want to troubleshoot the OrasPullNetworkTimeoutVMExtensionError error code (OrasPullNetworkTimeoutVMExtensionError (211)) so that I can successfully create and deploy an Azure Kubernetes Service (AKS) cluster.
8+
ms.custom: sap:Create, Upgrade, Scale and Delete operations (cluster or nodepool)
9+
---
10+
# OrasPullNetworkTimeoutVMExtensionError error code (211) when deploying an AKS cluster
11+
12+
This article discusses how to identify and resolve the `OrasPullNetworkTimeoutVMExtensionError` error (error code 211) that occurs when you try to create and deploy a Microsoft Azure Kubernetes Service (AKS) cluster.
13+
14+
## Symptoms
15+
16+
When you try to create an AKS cluster with the outbound type `none` or `block`, you receive the following error message:
17+
18+
> VMExtensionProvisioningError: VM has reported a failure when processing extension 'vmssCSE'.
19+
>
20+
> Error message: "Enable failed: failed to execute command: command terminated with exit status=211
21+
>
22+
> Bootstrap Container Registry is not reachable. Please check the network configuration and try again.
23+
24+
## Cause
25+
26+
For [network isolated cluster](/azure/aks/concepts-network-isolated), egress traffic is limited. The feature introduces private Azure Container Registry (ACR) cache that acts as a proxy to download necessary binaries or images from Microsoft Artifact Registry (MAR) for AKS bootstrap. VM instances connect to the private ACR via a private link. Incorrect configuration of the private link causes VM bootstrap Custom Script Extension (CSE) to fail.
27+
28+
## Solution
29+
30+
To resolve this issue, follow these steps:
31+
32+
1. Retrieve the ACR resource ID that AKS uses as the bootstrap ACR by running the following command:
33+
34+
```console
35+
az aks show -g ${RESOURCE_GROUP} -n ${CLUSTER_NAME} --query 'bootstrapProfile.containerRegistryResourceId'
36+
```
37+
38+
2. Verify the ACR cache rule. It should include `aks-managed-rule` with source repo `mcr.microsoft.com/*` and target repo `aks-managed-reposity/*`. Ensure no other cache rule exists with source or target repo as `*`, which override `aks-managed-rule`.
39+
40+
3. Review the [container registry private link](/azure/container-registry/container-registry-private-link) to ensure that the connection configuration is correct, including the private Domain Name System (DNS) zone and private link.
41+
42+
4. Access any failed VM instance using Secure Shell (SSH) and run curl on the ACR host. If successful, reconcile the cluster. If it still fails, return to step 3.
43+
44+
## References
45+
46+
- [General troubleshooting of AKS cluster creation issues](../create-upgrade-delete/troubleshoot-aks-cluster-creation-issues.md)
47+
48+
- [Network isolated Azure Kubernetes Service (AKS) clusters](/azure/aks/concepts-network-isolated)
49+
50+
- [Container registry private link](/azure/container-registry/container-registry-private-link)
51+
52+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: OrasPullUnauthorizedVMExtensionError When Creating AKS Clusters
3+
description: Learn how to troubleshoot the OrasPullUnauthorizedVMExtensionError error (212) when you try to create and deploy an Azure Kubernetes Service (AKS) cluster.
4+
ms.date: 05/09/2025
5+
ms.reviewer: xinhl, v-weizhu
6+
ms.service: azure-kubernetes-service
7+
#Customer intent: As an Azure Kubernetes user, I want to troubleshoot the OrasPullUnauthorizedVMExtensionError error code (OrasPullUnauthorizedVMExtensionError (212)) so that I can successfully create and deploy an Azure Kubernetes Service (AKS) cluster.
8+
ms.custom: sap:Create, Upgrade, Scale and Delete operations (cluster or nodepool)
9+
---
10+
# OrasPullUnauthorizedVMExtensionError error code (212) when deploying an AKS cluster
11+
12+
This article discusses how to identify and resolve the `OrasPullUnauthorizedVMExtensionError` error (error code 212) that occurs when you try to create and deploy a Microsoft Azure Kubernetes Service (AKS) cluster.
13+
14+
## Symptoms
15+
16+
When you try to create an AKS cluster with the outbound type `none` or `block`, you receive the following error message:
17+
18+
> VMExtensionProvisioningError: VM has reported a failure when processing extension 'vmssCSE'.
19+
>
20+
> Error message: "Enable failed: failed to execute command: command terminated with exit status=212
21+
>
22+
> Bootstrap Container Registry authorization failed. Please ensure kubelet identity has pull access to the registry.
23+
24+
## Cause
25+
26+
For [network isolated cluster](/azure/aks/concepts-network-isolated), egress traffic is limited. The feature introduces private Azure Container Registry (ACR) cache that acts as a proxy to download necessary binary or images from Microsoft Artifact Registry (MAR) for AKS bootstrap. It's suggested to disable anonymous access to the ACR. The AKS node uses the kubelet identity to access the ACR. If the `acrpull` permission isn't set correctly or the kubelet identity isn't bound to the VM instance, an unauthorized error occurs.
27+
28+
## Solution
29+
30+
To resolve this issue, follow these steps:
31+
32+
1. Access the VM instance using Secure Shell (SSH) to get the log file`/var/log/azure/cluster-provision.log`. Review the log to determine if the issue is related to a 401 error, Azure Instance Metadata Service (IMDS) connection time-out, or an identity not found with HTTP code 400.
33+
34+
2. Retrieve the ACR resource ID that AKS uses as the bootstrap ACR by running the following command:
35+
36+
```console
37+
export REGISTRY_ID=$(az aks show -g ${RESOURCE_GROUP} -n ${CLUSTER_NAME} --query 'bootstrapProfile.containerRegistryId' -o tsv)
38+
```
39+
40+
3. If the issue is related to a 401 error, check if the kubelet identity has the `acrpull` permission to the ACR by running the following command:
41+
42+
```console
43+
export KUBELET_IDENTITY_PRINCIPAL_ID=$(az aks show -g ${RESOURCE_GROUP} -n ${CLUSTER_NAME} --query 'identityProfile.kubeletidentity.clientId' -o tsv)
44+
```
45+
46+
If not, run the following command:
47+
48+
```console
49+
az role assignment create --role AcrPull --scope ${REGISTRY_ID} --assignee-object-id ${KUBELET_IDENTITY_PRINCIPAL_ID} --assignee-principal-type ServicePrincipal
50+
```
51+
52+
4. If the log error indicates that the identity isn't found, manually bind the kubelet identity to the Virtual Machine Scale Set (VMSS) for a quick fix.
53+
54+
5. If the issue is related to IMDS connection time-out, submit a support ticket.
55+
6. Reconcile the cluster if the preceding operations are completed.
56+
57+
## References
58+
59+
- [General troubleshooting of AKS cluster creation issues](../create-upgrade-delete/troubleshoot-aks-cluster-creation-issues.md)
60+
61+
- [Network isolated Azure Kubernetes Service (AKS) clusters](/azure/aks/concepts-network-isolated)
62+
63+
- [container registry authentication managed identity](/azure/container-registry/container-registry-authentication-managed-identity)
64+
65+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]

support/azure/azure-kubernetes/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@
358358
items:
359359
- name: VMExtension error codes
360360
items:
361+
- name: OrasPullNetworkTimeoutVMExtensionError
362+
href: error-codes/vmextensionerror-oraspullnetworktimeout.md
363+
- name: OrasPullUnauthorizedVMExtensionError
364+
href: error-codes/vmextensionerror-oraspullunauthorized.md
361365
- name: VMExtensionError_CniDownloadTimeout error
362366
href: error-codes/vmextensionerror-cnidownloadtimeout.md
363367
- name: VMExtensionError_OutboundConnFail error

support/azure/virtual-machines/windows/in-place-system-upgrade.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: In-place upgrade for supported VMs running Windows in Azure
33
description: Understand how to work around the unsupported in-place system upgrade on an Azure VM that runs Windows.
4-
ms.date: 3/18/2025
4+
ms.date: 05/09/2025
55
ms.reviewer: joscon, scotro, azurevmcptcic, maulikshah, yogitagohel, v-weizhu
66
ms.service: azure-virtual-machines
77
ms.collection: windows
@@ -47,7 +47,7 @@ In-place system upgrades are supported for specific versions of Azure Windows VM
4747
4848
### Windows versions not yet supported for in-place system upgrades (consider using a workaround)
4949

50-
- Windows 10 and 11 Enterprise multi-session, all versions
50+
- Windows 10 and 11 Enterprise multi-session, all versions (upgrade from single-session)
5151
- Windows 8.1
5252
- Windows 7 Enterprise
5353

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
title: Troubleshooting 401 Unauthorized Errors in ASP.NET Core Web API with Microsoft Entra ID Authentication
3+
description: Provides guidance for troubleshooting and resolving 401 Unauthorized errors in an ASP.NET Core Web API that uses Microsoft Entra ID authentication.
4+
ms.date: 04/28/2025
5+
ms.author: bachoang
6+
ms.service: entra-id
7+
ms.custom: sap:Developing or Registering apps with Microsoft identity platform
8+
---
9+
10+
# 401 Unauthorized errors in ASP.NET Core Web API with Microsoft Entra ID
11+
12+
When you call an ASP.NET Core Web API that's secured by using Microsoft Entra ID authentication, you might encounter a "401 Unauthorized" error. This article provides guidance for using `JwtBearerEvents` to capture detailed logs to troubleshoot these errors.
13+
14+
## Symptoms
15+
16+
You use the `[Authorize]` attribute to [secure your ASP.NET Core Web API](/entra/identity-platform/tutorial-web-api-dotnet-core-build-app?tabs=workforce-tenant), as follows:
17+
18+
```csharp
19+
[Authorize]
20+
public class MyController : ControllerBase
21+
{
22+
...
23+
}
24+
25+
```
26+
27+
Or
28+
29+
```csharp
30+
31+
public class MyController : ControllerBase
32+
{
33+
[Authorize]
34+
public ActionResult<string> Get(int id)
35+
{
36+
return "value";
37+
}
38+
...
39+
}
40+
```
41+
42+
When you call the web API, a "401 Unauthorized" response is returned, but the message contains no error details.
43+
44+
## Cause
45+
46+
The API might return a "401 Unauthorized" response in the following scenarios:
47+
48+
- The request doesn't include a valid "Authorization: Bearer" token header.
49+
- The token is expired or incorrect:
50+
- The token is issued for a different resource.
51+
- The token claims don't meet the application's token validation criteria, as defined in the [JwtBearerOptions.TokenValidationParameters](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbeareroptions.tokenvalidationparameters) class.
52+
53+
## Solution
54+
55+
To debug and resolve "401 Unauthorized" errors, use the `JwtBearerEvents` callbacks to capture and log detailed error information. Follow these steps to implement a custom error-handling mechanism.
56+
57+
The `JwtBearerEvents` class has the following callback properties (invoked in the following order) that can help you to debug these "401 Access Denied" or "UnAuthorization" issues:
58+
59+
- [`OnMessageRecieved`](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbearerevents.onmessagereceived#Microsoft_AspNetCore_Authentication_JwtBearer_JwtBearerEvents_OnMessageReceived) is called first for every request.
60+
- [`OnAuthenticationFailed`](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbearerevents.onauthenticationfailed) is called if the token doesn't pass the application's token validation criteria.
61+
- [`OnChallenge`](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbearerevents.onchallenge) is called last before a "401" response is returned.
62+
63+
### Step 1: Enable PII logging
64+
65+
By default, personally identifiable information (PII) logging is disabled. Enable it in the **Configure** method of the Startup.cs file for debugging.
66+
67+
> [!Caution]
68+
> Use 'Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true' only in a development environment for debugging. Do not use it in a production environment.
69+
70+
```csharp
71+
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
72+
{
73+
if (env.IsDevelopment())
74+
{
75+
app.UseDeveloperExceptionPage();
76+
}
77+
else
78+
{
79+
// The default HSTS value is 30 days. You might want to change this value for production scenarios. See https://aka.ms/aspnetcore-hsts.
80+
app.UseHsts();
81+
}
82+
// turn on PII logging
83+
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
84+
85+
app.UseHttpsRedirection();
86+
app.UseAuthentication();
87+
app.UseMvc();
88+
}
89+
```
90+
91+
### Step 2: Create a utility method to format exception messages
92+
93+
Add a method to format, and flatten any exception messages for better readability:
94+
95+
```csharp
96+
public static string FlattenException(Exception exception)
97+
{
98+
var stringBuilder = new StringBuilder();
99+
while (exception != null)
100+
{
101+
stringBuilder.AppendLine(exception.Message);
102+
stringBuilder.AppendLine(exception.StackTrace);
103+
exception = exception.InnerException;
104+
}
105+
return stringBuilder.ToString();
106+
}
107+
```
108+
109+
### Step 3: Implement JwtBearerEvents callbacks
110+
111+
Configure the `JwtBearerEvents` callbacks in the `ConfigureServices` method of *Startup.cs* to handle authentication events and log error details:
112+
113+
```csharp
114+
public void ConfigureServices(IServiceCollection services)
115+
{
116+
....
117+
.AddJwtBearer(options =>
118+
{
119+
options.Authority = "https://login.microsoftonline.com/<Tenant>.onmicrosoft.com";
120+
// if you intend to validate only one audience for the access token, you can use options.Audience instead of
121+
// using options.TokenValidationParameters which allow for more customization.
122+
// options.Audience = "10e569bc5-4c43-419e-971b-7c37112adf691";
123+
124+
options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
125+
{
126+
ValidAudiences = new List<string> { "<Application ID URI>", "10e569bc5-4c43-419e-971b-7c37112adf691" },
127+
ValidIssuers = new List<string> { "https://sts.windows.net/<Directory ID>/", "https://sts.windows.net/<Directory ID>/v2.0" }
128+
};
129+
130+
options.Events = new JwtBearerEvents
131+
{
132+
OnAuthenticationFailed = ctx =>
133+
{
134+
ctx.Response.StatusCode = StatusCodes.Status401Unauthorized;
135+
message += "From OnAuthenticationFailed:\n";
136+
message += FlattenException(ctx.Exception);
137+
return Task.CompletedTask;
138+
},
139+
140+
OnChallenge = ctx =>
141+
{
142+
message += "From OnChallenge:\n";
143+
ctx.Response.StatusCode = StatusCodes.Status401Unauthorized;
144+
ctx.Response.ContentType = "text/plain";
145+
return ctx.Response.WriteAsync(message);
146+
},
147+
148+
OnMessageReceived = ctx =>
149+
{
150+
message = "From OnMessageReceived:\n";
151+
ctx.Request.Headers.TryGetValue("Authorization", out var BearerToken);
152+
if (BearerToken.Count == 0)
153+
BearerToken = "no Bearer token sent\n";
154+
message += "Authorization Header sent: " + BearerToken + "\n";
155+
return Task.CompletedTask;
156+
},
157+
#For completeness, the sample code also implemented the OnTokenValidated property to log the token claims. This method is invoked when authentication is successful
158+
OnTokenValidated = ctx =>
159+
{
160+
Debug.WriteLine("token: " + ctx.SecurityToken.ToString());
161+
return Task.CompletedTask;
162+
}
163+
};
164+
});
165+
...
166+
}
167+
```
168+
169+
### Sample results
170+
171+
When you implement `JwtBearerEvents` callbacks, if a "401 Unauthorized" error occurs, the response output should include such details as the following example:
172+
173+
```Output
174+
OnMessageRecieved:
175+
176+
Authorization Header sent: no Bearer token sent.
177+
```
178+
179+
If you use the API development tool to debug the request, you should receive error details, as shown in the following screenshot.
180+
181+
:::image type="content" source="media/401-unauthorized-aspnet-core-web-api/wrong-token.png" alt-text="Screenshot of error details in the API development tool." lightbox="media/401-unauthorized-aspnet-core-web-api/wrong-token.png":::
182+
183+
[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)]

0 commit comments

Comments
 (0)