Skip to content

Commit b74e537

Browse files
authored
Update tutorial-connect-msi-azure-database.md
This edit is related to [this question](https://learn.microsoft.com/en-us/answers/questions/1135062/how-to-solve-azure-core-exceptions-clientauthentic).
1 parent e8ddf93 commit b74e537

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

articles/app-service/tutorial-connect-msi-azure-database.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ In this section, connectivity to the Azure database in your code follows the `De
251251
1. Instantiate a `DefaultAzureCredential` from the Azure Identity client library. If you're using a user-assigned identity, specify the client ID of the identity.
252252
1. Get an access token for the resource URI respective to the database type.
253253
- For Azure SQL Database: `https://database.windows.net/.default`
254-
- For Azure Database for MySQL: `https://ossrdbms-aad.database.windows.net`
255-
- For Azure Database for PostgreSQL: `https://ossrdbms-aad.database.windows.net`
254+
- For Azure Database for MySQL: `https://ossrdbms-aad.database.windows.net/.default`
255+
- For Azure Database for PostgreSQL: `https://ossrdbms-aad.database.windows.net/.default`
256256
1. Add the token to your connection string.
257257
1. Open the connection.
258258
@@ -319,7 +319,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
319319
//var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = '<client-id-of-user-assigned-identity>' }); // user-assigned identity
320320
321321
// Get token for Azure Database for MySQL
322-
var token = credential.GetToken(new Azure.Core.TokenRequestContext(new[] { "https://ossrdbms-aad.database.windows.net" }));
322+
var token = credential.GetToken(new Azure.Core.TokenRequestContext(new[] { "https://ossrdbms-aad.database.windows.net/.default" }));
323323
324324
// Set MySQL user depending on the environment
325325
string user;
@@ -351,7 +351,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
351351
//var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = '<client-id-of-user-assigned-identity>' }); // user-assigned identity
352352
353353
// Get token for Azure Database for PostgreSQL
354-
var token = credential.GetToken(new Azure.Core.TokenRequestContext(new[] { "https://ossrdbms-aad.database.windows.net" }));
354+
var token = credential.GetToken(new Azure.Core.TokenRequestContext(new[] { "https://ossrdbms-aad.database.windows.net/.default" }));
355355
356356
// Check if in Azure and set user accordingly
357357
string postgresqlUser;
@@ -431,7 +431,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
431431
//var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = '<client-id-of-user-assigned-identity>' }); // user-assigned identity
432432
433433
// Get token for Azure Database for MySQL
434-
var token = credential.GetToken(new Azure.Core.TokenRequestContext(new[] { "https://ossrdbms-aad.database.windows.net" }));
434+
var token = credential.GetToken(new Azure.Core.TokenRequestContext(new[] { "https://ossrdbms-aad.database.windows.net/.default" }));
435435
436436
// Set MySQL user depending on the environment
437437
string user;
@@ -465,7 +465,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
465465
//var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = '<client-id-of-user-assigned-identity>' }); // user-assigned identity
466466
467467
// Get token for Azure Database for PostgreSQL
468-
var token = credential.GetToken(new Azure.Core.TokenRequestContext(new[] { "https://ossrdbms-aad.database.windows.net" }));
468+
var token = credential.GetToken(new Azure.Core.TokenRequestContext(new[] { "https://ossrdbms-aad.database.windows.net/.default" }));
469469
470470
// Check if in Azure and set user accordingly
471471
string postgresqlUser;
@@ -563,7 +563,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
563563
//const credential = new DefaultAzureCredential({ managedIdentityClientId: '<client-id-of-user-assigned-identity>' }); // user-assigned identity
564564
565565
// Get token for Azure Database for MySQL
566-
const accessToken = await credential.getToken("https://ossrdbms-aad.database.windows.net");
566+
const accessToken = await credential.getToken("https://ossrdbms-aad.database.windows.net/.default");
567567
568568
// Set MySQL user depending on the environment
569569
if(process.env.IDENTITY_ENDPOINT) {
@@ -617,7 +617,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
617617
//const credential = new DefaultAzureCredential({ managedIdentityClientId: '<client-id-of-user-assigned-identity>' }); // user-assigned identity
618618
619619
// Get token for Azure Database for PostgreSQL
620-
const accessToken = await credential.getToken("https://ossrdbms-aad.database.windows.net");
620+
const accessToken = await credential.getToken("https://ossrdbms-aad.database.windows.net/.default");
621621
622622
// Set PosrgreSQL user depending on the environment
623623
if(process.env.IDENTITY_ENDPOINT) {
@@ -719,7 +719,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
719719
#credential = DefaultAzureCredential(managed_identity_client_id='<client-id-of-user-assigned-identity>') # user-assigned identity
720720
721721
# Get token for Azure Database for MySQL
722-
token = credential.get_token("https://ossrdbms-aad.database.windows.net")
722+
token = credential.get_token("https://ossrdbms-aad.database.windows.net/.default")
723723
724724
# Set MySQL user depending on the environment
725725
if 'IDENTITY_ENDPOINT' in os.environ:
@@ -754,7 +754,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
754754
#credential = DefaultAzureCredential(managed_identity_client_id='<client-id-of-user-assigned-identity>') # user-assigned identity
755755
756756
# Get token for Azure Database for PostgreSQL
757-
token = credential.get_token("https://ossrdbms-aad.database.windows.net")
757+
token = credential.get_token("https://ossrdbms-aad.database.windows.net/.default")
758758
759759
# Set PostgreSQL user depending on the environment
760760
if 'IDENTITY_ENDPOINT' in os.environ:
@@ -884,7 +884,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
884884
885885
// Get the token
886886
TokenRequestContext request = new TokenRequestContext();
887-
request.addScopes("https://ossrdbms-aad.database.windows.net");
887+
request.addScopes("https://ossrdbms-aad.database.windows.net/.default");
888888
AccessToken token=creds.getToken(request).block();
889889
890890
// Set MySQL user depending on the environment
@@ -930,7 +930,7 @@ For Azure Database for MySQL and Azure Database for PostgreSQL, the database use
930930
931931
// Get the token
932932
TokenRequestContext request = new TokenRequestContext();
933-
request.addScopes("https://ossrdbms-aad.database.windows.net");
933+
request.addScopes("https://ossrdbms-aad.database.windows.net/.default");
934934
AccessToken token=creds.getToken(request).block();
935935
936936
// Set PostgreSQL user depending on the environment

0 commit comments

Comments
 (0)