diff --git a/eng/.docsettings.yml b/eng/.docsettings.yml
index ca21a1741d9fc..ba11e8494604a 100644
--- a/eng/.docsettings.yml
+++ b/eng/.docsettings.yml
@@ -9,6 +9,9 @@ omitted_paths:
- samples/*
- sdk/*/*.Management.*/*
- sdk/*/*/perf/*
+ - sdk/*/*/integration/*
+ - sdk/*/*/tests/Samples/*
+ - sdk/*/*/tests/samples/*
- sdk/*/*/samples/*
- sdk/*/samples/*
- sdk/*/swagger/*
diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props
index 8e7dc2ecb658c..cefa93d71937c 100644
--- a/eng/Packages.Data.props
+++ b/eng/Packages.Data.props
@@ -102,15 +102,15 @@
-
-
-
-
+
+
+
+
-
+
diff --git a/sdk/identity/Azure.Identity/CHANGELOG.md b/sdk/identity/Azure.Identity/CHANGELOG.md
index ea6cc121c2021..d8f5cd3b4c84e 100644
--- a/sdk/identity/Azure.Identity/CHANGELOG.md
+++ b/sdk/identity/Azure.Identity/CHANGELOG.md
@@ -1,4 +1,9 @@
# Release History
+## 1.8.2 (2023-02-08)
+
+### Bugs Fixed
+- Fixed error message parsing in `AzurePowerShellCredential` which would misinterpret AAD errors with the need to install PowerShell. [#31998](https://github.com/Azure/azure-sdk-for-net/issues/31998)
+- Fix regional endpoint validation error when using `ManagedIdentityCredential`. [#32498])(https://github.com/Azure/azure-sdk-for-net/issues/32498)
## 1.8.1 (2023-01-13)
diff --git a/sdk/identity/Azure.Identity/integration/WebApp/Controllers/TestController.cs b/sdk/identity/Azure.Identity/integration/WebApp/Controllers/TestController.cs
new file mode 100644
index 0000000000000..0e792196f251a
--- /dev/null
+++ b/sdk/identity/Azure.Identity/integration/WebApp/Controllers/TestController.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Linq;
+using Azure.Core;
+using Azure.Identity;
+using Azure.Storage.Blobs;
+using Microsoft.AspNetCore.Mvc;
+
+namespace WebApp.Controllers
+{
+
+ [ApiController]
+ [Route("[controller]")]
+ public class TestController : ControllerBase
+ {
+
+ [HttpGet(Name = "GetTest")]
+ public IActionResult Get()
+ {
+ string resourceId = Environment.GetEnvironmentVariable("IDENTITY_WEBAPP_USER_DEFINED_IDENTITY")!;
+ string account1 = Environment.GetEnvironmentVariable("IDENTITY_STORAGE_NAME_1")!;
+ string account2 = Environment.GetEnvironmentVariable("IDENTITY_STORAGE_NAME_2")!;
+
+ var credential1 = new ManagedIdentityCredential();
+ var credential2 = new ManagedIdentityCredential(new ResourceIdentifier(resourceId));
+ var client1 = new BlobServiceClient(new Uri($"https://{account1}.blob.core.windows.net/"), credential1);
+ var client2 = new BlobServiceClient(new Uri($"https://{account2}.blob.core.windows.net/"), credential2);
+ try
+ {
+ var results = client1.GetBlobContainers().ToList();
+ results = client2.GetBlobContainers().ToList();
+ return Ok("Successfully acquired a token from ManagedIdentityCredential");
+ }
+ catch (Exception ex)
+ {
+ return BadRequest(ex.ToString());
+ }
+ }
+ }
+}
diff --git a/sdk/identity/Azure.Identity/integration/WebApp/Integration.Identity.WebApp.csproj b/sdk/identity/Azure.Identity/integration/WebApp/Integration.Identity.WebApp.csproj
new file mode 100644
index 0000000000000..8460903024cfe
--- /dev/null
+++ b/sdk/identity/Azure.Identity/integration/WebApp/Integration.Identity.WebApp.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/identity/Azure.Identity/integration/WebApp/Program.cs b/sdk/identity/Azure.Identity/integration/WebApp/Program.cs
new file mode 100644
index 0000000000000..70c0b74c91a90
--- /dev/null
+++ b/sdk/identity/Azure.Identity/integration/WebApp/Program.cs
@@ -0,0 +1,21 @@
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.DependencyInjection;
+
+var builder = WebApplication.CreateBuilder(args);
+
+// Add services to the container.
+
+builder.Services.AddControllers();
+// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
+builder.Services.AddEndpointsApiExplorer();
+
+var app = builder.Build();
+
+// Configure the HTTP request pipeline.
+app.UseHttpsRedirection();
+
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.Run();
diff --git a/sdk/identity/Azure.Identity/integration/WebApp/appsettings.Development.json b/sdk/identity/Azure.Identity/integration/WebApp/appsettings.Development.json
new file mode 100644
index 0000000000000..0c208ae9181e5
--- /dev/null
+++ b/sdk/identity/Azure.Identity/integration/WebApp/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/sdk/identity/Azure.Identity/integration/WebApp/appsettings.json b/sdk/identity/Azure.Identity/integration/WebApp/appsettings.json
new file mode 100644
index 0000000000000..10f68b8c8b4f7
--- /dev/null
+++ b/sdk/identity/Azure.Identity/integration/WebApp/appsettings.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*"
+}
diff --git a/sdk/identity/Azure.Identity/integration/nuget.config b/sdk/identity/Azure.Identity/integration/nuget.config
new file mode 100644
index 0000000000000..9ac17c067abd9
--- /dev/null
+++ b/sdk/identity/Azure.Identity/integration/nuget.config
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sdk/identity/Azure.Identity/src/Azure.Identity.csproj b/sdk/identity/Azure.Identity/src/Azure.Identity.csproj
index 1a86651681371..7c2723fb7c0bc 100644
--- a/sdk/identity/Azure.Identity/src/Azure.Identity.csproj
+++ b/sdk/identity/Azure.Identity/src/Azure.Identity.csproj
@@ -2,9 +2,9 @@
This is the implementation of the Azure SDK Client Library for Azure Identity
Microsoft Azure.Identity Component
- 1.8.1
+ 1.8.2
- 1.8.0
+ 1.8.1
Microsoft Azure Identity;$(PackageCommonTags)
$(RequiredTargetFrameworks)
$(NoWarn);3021;AZC0011
diff --git a/sdk/identity/Azure.Identity/src/Credentials/AzurePowerShellCredential.cs b/sdk/identity/Azure.Identity/src/Credentials/AzurePowerShellCredential.cs
index 6a51c09fdc40d..c7d61aadf5980 100644
--- a/sdk/identity/Azure.Identity/src/Credentials/AzurePowerShellCredential.cs
+++ b/sdk/identity/Azure.Identity/src/Credentials/AzurePowerShellCredential.cs
@@ -27,7 +27,7 @@ public class AzurePowerShellCredential : TokenCredential
internal bool UseLegacyPowerShell { get; set; }
private const string Troubleshooting = "See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/powershellcredential/troubleshoot";
- private const string AzurePowerShellFailedError = "Azure PowerShell authentication failed due to an unknown error. " + Troubleshooting;
+ internal const string AzurePowerShellFailedError = "Azure PowerShell authentication failed due to an unknown error. " + Troubleshooting;
private const string RunConnectAzAccountToLogin = "Run Connect-AzAccount to login";
private const string NoAccountsWereFoundInTheCache = "No accounts were found in the cache";
private const string CannotRetrieveAccessToken = "cannot retrieve access token";
@@ -170,8 +170,10 @@ private async ValueTask RequestAzurePowerShellAccessTokenAsync(bool
private static void CheckForErrors(string output)
{
- bool noPowerShell = output.IndexOf("not found", StringComparison.OrdinalIgnoreCase) != -1 ||
- output.IndexOf("is not recognized", StringComparison.OrdinalIgnoreCase) != -1;
+ bool noPowerShell = (output.IndexOf("not found", StringComparison.OrdinalIgnoreCase) != -1 ||
+ output.IndexOf("is not recognized", StringComparison.OrdinalIgnoreCase) != -1) &&
+ // If the error contains AADSTS, this should be treated as a general error to be bubbled to the user
+ output.IndexOf("AADSTS", StringComparison.OrdinalIgnoreCase) == -1;
if (noPowerShell)
{
throw new CredentialUnavailableException(PowerShellNotInstalledError);
diff --git a/sdk/identity/Azure.Identity/src/MsalConfidentialClient.cs b/sdk/identity/Azure.Identity/src/MsalConfidentialClient.cs
index e45dd7c812d08..5b7779a9cfb14 100644
--- a/sdk/identity/Azure.Identity/src/MsalConfidentialClient.cs
+++ b/sdk/identity/Azure.Identity/src/MsalConfidentialClient.cs
@@ -12,7 +12,6 @@ namespace Azure.Identity
{
internal class MsalConfidentialClient : MsalClientBase
{
- private const string s_instanceMetadata = "{\"tenant_discovery_endpoint\":\"https://login.microsoftonline.com/common/v2.0/.well-known/openid-configuration\",\"api-version\":\"1.1\",\"metadata\":[{\"preferred_network\":\"login.microsoftonline.com\",\"preferred_cache\":\"login.windows.net\",\"aliases\":[\"login.microsoftonline.com\",\"login.windows.net\",\"login.microsoft.com\",\"sts.windows.net\"]}]}";
internal readonly string _clientSecret;
internal readonly bool _includeX5CClaimHeader;
internal readonly IX509Certificate2Provider _certificateProvider;
@@ -76,7 +75,7 @@ protected override async ValueTask CreateClientA
{
confClientBuilder.WithAppTokenProvider(_appTokenProviderCallback)
.WithAuthority(_authority.AbsoluteUri, TenantId, false)
- .WithInstanceDiscoveryMetadata(s_instanceMetadata);
+ .WithInstanceDiscovery(false);
}
else
{
@@ -104,6 +103,7 @@ protected override async ValueTask CreateClientA
confClientBuilder.WithCertificate(clientCertificate);
}
+ // When the appTokenProviderCallback is set, meaning this is for managed identity, the regional authority is not relevant.
if (_appTokenProviderCallback == null && !string.IsNullOrEmpty(RegionalAuthority))
{
confClientBuilder.WithAzureRegion(RegionalAuthority);
diff --git a/sdk/identity/Azure.Identity/tests/AzurePowerShellCredentialsTests.cs b/sdk/identity/Azure.Identity/tests/AzurePowerShellCredentialsTests.cs
index a812955a46934..ebbfd9c12c1f4 100644
--- a/sdk/identity/Azure.Identity/tests/AzurePowerShellCredentialsTests.cs
+++ b/sdk/identity/Azure.Identity/tests/AzurePowerShellCredentialsTests.cs
@@ -93,21 +93,25 @@ public override async Task VerifyAllowedTenantEnforcement(AllowedTenantsTestPara
private static IEnumerable