gpt4 book ai didi

java - ServiceBusConfiguration.configureWithConnectionString 无法工作,错误 "The key ' SharedAccessKeyName' 对于此连接字符串无效”

转载 作者:行者123 更新时间:2023-12-03 00:33:05 25 4
gpt4 key购买 nike

我正在使用最新的Azure java sdk(版本0.6),但我发现在使用服务总线配置“configureWithConnectionString”功能时遇到问题。下面是我的代码,

//get config
string connectionString = "Endpoint=sb://testservicebusnamespace.servicebus.windows.net/;SharedAccessKeyName=MySharedAccessKey;SharedAccessKey=<this is secret not show>";
config = new Configuration();
ServiceBusConfiguration.configureWithConnectionString(null, config, connectionString);

//create service
service = ServiceBusService.create(config);

我从 Azure 中的服务总线命名空间门户获取连接字符串。但是当我运行此代码时,它会抛出异常“ key ‘SharedAccessKeyName’对此连接字符串无效”。

我不知道问题出在哪里,因为我从 Azure 门户获得连接,并且我检查了其内容(SharedAccessKeyName、SharedAccessKey),它们是正确的。

那么有人可以帮助我吗?是我的问题还是这个 SDK 需要更新(因为我听说门户已经使用 SAS,但 SDK 仍然使用 ACS 进行身份验证)?

非常感谢。

最佳答案

看来Java Azure SDK(0.6.0)仍然使用ACS进行身份验证。请参阅this github issue评论:

the current SDK works with service bus namespace with ACS auth mode, but not new created servicebus namespace which use SAS token auth mode. we will investigate this issue

One workaround is to create the service bus namespace via PowerShell. This seems to enable the ACS auth mode by default. Command is:

New-AzureSBNameSpace -Name MyNameSpace -Location "West Europe"

Take a note of the "DefaultKey" you get after running the command. You need to use that with the ServiceBusConfiguration and I'm not sure if that is available via the Azure management portal. Use "owner" as the authenticationName parameter to the configureWithWrapAuthentication.

关于java - ServiceBusConfiguration.configureWithConnectionString 无法工作,错误 "The key ' SharedAccessKeyName' 对于此连接字符串无效”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27271397/

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