gpt4 book ai didi

azure - @azure/identity node.js 无法进行身份验证

转载 作者:行者123 更新时间:2023-12-02 23:38:55 25 4
gpt4 key购买 nike

我一直在关注互联网上可以找到的每个示例,以便我能够使用应用程序身份通过 js/node 通过 azure 进行身份验证,如下例所示:

        const account = process.env.ACCOUNT_NAME || '';

// Azure AD Credential information is required to run this sample:
if (
!process.env.AZURE_TENANT_ID ||
!process.env.AZURE_CLIENT_ID ||
!process.env.AZURE_CLIENT_SECRET
) {
console.warn(
'Azure AD authentication information not provided, but it is required to run this sample. Exiting.'
);
return {
success: false,
message:
'Azure AD authentication information not provided, but it is required to run this sample. Exiting.',
};
}
const defaultAzureCredential = new DefaultAzureCredential();

console.log('credential', defaultAzureCredential);

我的代码中包含所有环境变量,并且我已经检查、双重检查和三次检查这些都是准确的。

当尝试运行代码时,我在 console.log 中收到此错误:

credential DefaultAzureCredential {
UnavailableMessage: 'DefaultAzureCredential => failed to retrieve a token from the included credentials',
_sources: [
EnvironmentCredential { _credential: [ClientSecretCredential] },
ManagedIdentityCredential {
isEndpointUnavailable: null,
identityClient: [IdentityClient]
},
ManagedIdentityCredential {
isEndpointUnavailable: null,
clientId: '04e6dd8e-0000-0000-0000-eb9b3eb60e27',
identityClient: [IdentityClient]
},
AzureCliCredential {},
VisualStudioCodeCredential {
cloudName: 'AzureCloud',
identityClient: [IdentityClient],
tenantId: 'common'
}
]
}

我现在完全陷入困境了。我不想使用共享访问 token ,因为需要连接到多个存储帐户(甚至使用这些凭据来创建新的存储帐户)。

非常欢迎任何建议、调试或建议......

最佳答案

DefaultAzureCredential 在您的问题中有效,即使它显示不可用消息。

您可以控制台EnvironmentCredential,它将包含环境变量。

enter image description here

注意:如果您只是使用环境变量,我建议您使用EnvironmentCredential。

DefaultAzureCredential and EnvironmentCredential can be configuredwith environment variables.

使用 DefaultAzureCredential 获取 key 保管库中的 secret :

enter image description here

关于azure - @azure/identity node.js 无法进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65921666/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com