无法为 Azure Nodejs SDK 指定中国区域

Not able to specify China Region for Azure Nodejs SDK

我正在尝试使用 Nodejs 与 Azure 中国资源进行交互。

但是没找到如何使用nodejs SDK 对Azure China 的应用程序进行身份验证。

尝试过@azure/arm-storage

import * as msRestNodeAuth from "@azure/ms-rest-nodeauth";

import { StorageManagementClient, StorageManagementModels, StorageManagementMappers } from "@azure/arm-storage";

const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"];


msRestNodeAuth.interactiveLogin().then((creds) => {
  const client = new StorageManagementClient(creds, subscriptionId);
  client.operations.list().then((result) => {
    console.log("The result is:");
    console.log(result);
  });
}).catch((err) => {
  console.error(err);
});

要连接到 Azure China,您需要指定环境。请看下面的代码:

const msRestNodeAuth = require("@azure/ms-rest-nodeauth");
const Environment = require("@azure/ms-rest-azure-env").Environment;

const mooncake = Environment.ChinaCloud;

msRestNodeAuth.interactiveLogin({
  environment: mooncake
}).then((creds) => {
  console.log(creds);
}).catch((err) => {
  console.error(err);
});