0

我正在尝试使用 Nodejs 与 Azure China Resources 进行交互。

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

试过了@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);
});

4

1 回答 1

1

要连接到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);
});
于 2019-05-23T12:21:39.910 回答