@azure/identity node.js 无法验证
@azure/identity node.js cannot authenticate
我一直在关注我在 Internet 上可以找到的每个示例,使我能够按照以下示例使用应用程序身份通过 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'
}
]
}
我现在完全卡住了。由于需要连接到多个存储帐户(甚至使用这些凭据创建新的存储帐户),我不想使用共享访问令牌。)
非常欢迎任何意见、调试或建议....
您的问题中的 DefaultAzureCredential
有效 ,即使它显示不可用消息。
您可以控制台 EnvironmentCredential
,它将包含环境变量。
注意:如果您只是使用环境变量,我建议您使用 EnvironmentCredential。
DefaultAzureCredential and EnvironmentCredential can be configured
with environment variables.
使用 DefaultAzureCredential 在密钥保管库中获取机密:
我一直在关注我在 Internet 上可以找到的每个示例,使我能够按照以下示例使用应用程序身份通过 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'
}
]
}
我现在完全卡住了。由于需要连接到多个存储帐户(甚至使用这些凭据创建新的存储帐户),我不想使用共享访问令牌。)
非常欢迎任何意见、调试或建议....
您的问题中的 DefaultAzureCredential
有效 ,即使它显示不可用消息。
您可以控制台 EnvironmentCredential
,它将包含环境变量。
注意:如果您只是使用环境变量,我建议您使用 EnvironmentCredential。
DefaultAzureCredential and EnvironmentCredential can be configured with environment variables.
使用 DefaultAzureCredential 在密钥保管库中获取机密: