【发布时间】:2021-01-14 18:57:37
【问题描述】:
编辑:我刚刚意识到下面的 AccountName 指的是我尚未创建的存储帐户。我认为这只是我拥有的一般天蓝色“帐户”。令人失望。
我正在处理this Java/Azure 文件存储示例。我遇到了一个问题,我无法找到解决方案:
英文:https://docs.microsoft.com/en-us/azure/storage/files/storage-java-how-to-use-file-storage?tabs=java
createFileShare 异常:java.net.UnknownHostException:2 次查询后无法解析“my-provided-accountname.file.core.windows.net”
我不确定究竟为 AccountName 提供什么,在较小程度上提供 AccountKey,我认为这是正确的。
我的混淆代码:
public static final String connectStr =
"DefaultEndpointsProtocol=https;" +
"AccountName=my-provided-accountname;" +
"AccountKey=87D2A2E999180C4A624E1A8153CEBD6";
public static void main(String[] args) {
SpringApplication.run(AzureFileStorageApplication.class, args);
ShareClient shareClient = new ShareClientBuilder()
.connectionString(connectStr).shareName("testfilestorage")
.buildClient();
createFileShare(connectStr,"hello1A");
}
public static Boolean createFileShare(String connectStr, String shareName)
{
try
{
ShareClient shareClient = new ShareClientBuilder()
.connectionString(connectStr).shareName(shareName)
.buildClient();
shareClient.create();
System.out.println(shareClient);
return true;
}
catch (Exception e)
{
System.out.println("createFileShare exception: " + e.getMessage());
return false;
}
}
【问题讨论】:
-
你有那个教程的英文链接吗?
-
我提供了一个链接,也许教程这个词太强了。点击上方的“这个”。
-
我在德国,chrome 会自动将我带到英语。
-
我实际上没有使用过 Azure 文件存储,但我希望 URL 是
https://<name>.file.core.windows.net/,而不仅仅是<name>.core