【发布时间】:2020-08-10 11:42:46
【问题描述】:
我创建了一个函数,可以让我获得订阅中的资源组列表
// Function to get the resource group
const getHttp = async (subscriptionId) => {
const response = await fetch(
`https://management.azure.com/subscriptions/${subscriptionId}/resourcegroups?api-version=2019-10-01`
);
if (response.status === 200) {
const data = await response.json();
return data;
} else {
throw new Error(
'Unable to get list of resource group from Azure' +
' ' +
response.status
);
}
};
module.exports = async function (context, req) {
context.log('ListRG proccessed a request');
const subscriptionId = 'xxx';
const json = await getHttp(subscriptionId);
console.log(json);
context.log(json);
context.res = { body: json };
};
但我明白了:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
这个错误:
2020-08-07T11:25:27.915 [Error] Executed 'Functions.ListRg' (Failed, Id=4a10c117-5ded-4bb4-882e-94ec4eb6e28b, Duration=36ms)Result: FailureException: Error: Unable to get list of resource group from AzureStack: Error: Unable to get list of resource group from Azureat getHttp (D:\home\site\wwwroot\ListRg\index.js:12:9)at processTicksAndRejections (internal/process/task_queues.js:97:5)at async module.exports (D:\home\site\wwwroot\ListRg\index.js:20:15)
对于权限,我使用托管身份并在我的订阅中赋予函数 Reader 角色
我错过了什么?
【问题讨论】:
标签: node.js azure azure-functions