gpt4 book ai didi

c# - 客户端地址未经授权,并且调用者不是 Azure 中的受信任服务

转载 作者:行者123 更新时间:2023-12-02 05:51:30 25 4
gpt4 key购买 nike

我正在 Azure 上工作。我有一个访问 Azure Key Vault 的 Windows 服务。

我的代码看起来像这样:

public static async Task<string> GetToken(string authority, string resource, string scope)
{
var authContext = new AuthenticationContext(authority);
ClientCredential clientCred = new ClientCredential(...); //app id, app secret
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientCred);

if (result == null)
throw new InvalidOperationException("Failed to obtain the JWT token");

return result.AccessToken;
}

public static string GetSecret(string secretName)
{
KeyVaultClient keyVaultClient = new KeyVaultClient(GetToken);
try
{
return keyVaultClient.GetSecretAsync("my-key-vault-url", secretName).Result.Value;
}
catch(Exception ex)
{
return "Error";
}
}

在构建并部署 Windows 服务后,我启动了它。然后我得到这个异常:

Client address (IPaddress) is not authorized and caller is not a trusted service

但是,我可以通过 telnet 访问 key 保管库:

telnet projectName-keyvault 443

我已经搜索过这个问题,但找不到任何解决方案。这方面的任何帮助都将非常有帮助。

最佳答案

该错误正确地表明您的客户端 IP 地址未经授权。

如果您启用了该设置,则需要在 Azure keyvault 中添加客户端 IP。

Azure > Keyvault > Networking Settings

进一步阅读:

关于c# - 客户端地址未经授权,并且调用者不是 Azure 中的受信任服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52985252/

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