【发布时间】:2020-07-14 19:48:22
【问题描述】:
当我使用“ms-rest-azure”库获取 Azure 凭据时。
let credentials = await msRestAzure.loginWithServicePrincipalSecret(id, secret, tanent);
let newCred = JSON.stringify(credentials);
let duplicateCred = JSON.parse(newCred); // Create duplicate credentials object
现在,如果我要在进一步的 Azure 函数调用中使用“duplicateCred”,则会收到上述错误。 但是,如果我使用“凭据”,那么一切都很好。 那么如何将“凭据”对象分配给其他变量?这样我就可以在未来的天蓝色 API 调用中使用该变量。
例子:
let credentials = await msRestAzure.loginWithServicePrincipalSecret(id, secret, tanent);
let newCred = JSON.stringify(credentials);
let duplicateCred = JSON.parse(newCred); // Create duplicate credentials object
// Okay, here I'm getting the proper client object. Because I am using "credentials" in the below line of code.
// I'm getting the results from the below lines of code.
const client = new MonitorManagementClient(credentials, subscription);
const results = await client.operations.list();
context.log('results==> ', results);
// Error, here not getting the proper client object. Because I am using "duplicateCred" as credentials in the below line of code.
// I'm not getting the results from the below lines of code.
// At the below line I'm getting the above error.
const client = new MonitorManagementClient(duplicateCred, subscription);
const results = await client.operations.list();
context.log('results==> ', results);
如何从实际凭据对象创建重复的凭据对象?
【问题讨论】:
标签: javascript node.js azure azure-functions azure-sdk