From 385cacb1eafcbe3f4adec9b4b21b19b96a5ad3c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodr=C3=ADguez?= Date: Thu, 17 Feb 2022 19:56:57 -0500 Subject: [PATCH] Reusing environment.resourceManagerEndpointUrl --- migrate-to-identity-v2.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/migrate-to-identity-v2.md b/migrate-to-identity-v2.md index 250b44e..b6b9a08 100644 --- a/migrate-to-identity-v2.md +++ b/migrate-to-identity-v2.md @@ -110,7 +110,7 @@ You will continue specifying a `baseUri` when creating the client in the Azure p ```diff - import { loginWithServicePrincipalSecret } from "@azure/ms-rest-nodeauth"; + import { ClientSecretCredential, AzureAuthorityHosts } from "@azure/identity"; -- import { Environment } from "@azure/ms-rest-azure-env"; +import { Environment } from "@azure/ms-rest-azure-env"; import { SubscriptionClient } from "@azure/arm-subscriptions"; import * as msRest from "@azure/ms-rest-js"; @@ -121,15 +121,14 @@ dotenv.config(); const clientId = process.env.AZURE_CLIENT_ID; const domain = process.env.AZURE_TENANT_ID; // domain or tenantId const secret = process.env.AZURE_CLIENT_SECRET; -- const environment = Environment.ChinaCloud; +const environment = Environment.ChinaCloud; + const authorityHost = AzureAuthorityHosts.AzureChina; async function main() { - const credential = await loginWithServicePrincipalSecret(clientId, secret, domain, { environment }); + const credential = new ClientSecretCredential(domain, clientId, secret, { authorityHost }); const client = new SubscriptionClient(credential, { -- baseUri: environment.resourceManagerEndpointUrl, -+ baseUri: "https://management.chinacloudapi.cn" + baseUri: environment.resourceManagerEndpointUrl, }); const subscriptions = await client.subscriptions.list();