Not able to specify China Region for Azure Nodejs SDK

134 Views Asked by At

I'm trying to interact with Azure China Resources with Nodejs.

But could not find out how to authenticate the application with Azure China with nodejs SDK.

Tried @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);
});

1

There are 1 best solutions below

0
Gaurav Mantri On BEST ANSWER

To connect to Azure China, you will need to specify the environment. Please see the code below:

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);
});