我已经使用 ClientSecretCredential 访问了 Azure 存储队列方法,但是在访问队列 receiveMessages、队列 peekMessages 和 deleteMessages 时,它给了我错误
RestError:此请求无权使用此权限执行此操作。请求ID:c92577923e-a603-0004-61c0-f70a19000
这是我的节点 js 代码
const { QueueServiceClient } = require("@azure/storage-queue");
const { ClientSecretCredential } = require("@azure/identity");
async function getQueueMessages() {
try {
let myStorageAccount = "hellostorage";
const credential = new ClientSecretCredential(tenantId, app_id, SecretKey);
const queueServiceClient = new QueueServiceClient(
`https://${myStorageAccount}.queue.core.windows.net`,
credential
);
const queueName = "hello-queue";
const queueClient = queueServiceClient.getQueueClient(queueName);
const response = await queueClient.receiveMessages(10);
console.log("response: ", response);
} catch (error) {
console.log("error: ", error);
}
}
getQueueMessages();