【发布时间】:2022-10-20 16:14:49
【问题描述】:
上下文:我正在构建一个 Web 应用程序,它从 json 文件中读取数据,我的计划是将这些 json 平面文件托管在 Azure blob 存储中,然后通过 API 将它们公开给我的 Web 应用程序。现在,我正在尝试构建一个本地开发环境。
我的短期目标是在 docker 容器中设置 azurite 并构建一个简单的控制台应用程序,该应用程序连接到本地 azurite 模拟器并读取一个 json 文件。
首先,我使用 docker compose 文件在 docker 容器中运行 azurite。
version: '3.9'
services:
azurite:
image: mcr.microsoft.com/azure-storage/azurite
container_name: 'azurite-console'
hostname: azurite
restart: always
command: 'azurite --oauth basic --cert /workspace/127.0.0.1.pem --key /workspace/127.0.0.1-key.pem'
ports:
- 10000:10000
- 10001:10001
- 10002:10002
volumes:
- ./certs:/workspace
这似乎工作得很好,请注意 https:
我使用mkcert 创建了证书
但是,如果我运行以下
static void Main(string[] args)
{
// With container URL and DefaultAzureCredential
var client = new BlobServiceClient(
new Uri("https://127.0.0.1:10000"),
new DefaultAzureCredential()
);
Console.WriteLine("\nlist containers");
try
{
var containers = client.GetBlobContainers();
foreach (var c in containers)
Console.WriteLine(c.Name);
}
catch(Exception ex){
Console.WriteLine(ex.Message);
}
}
我得到以下异常:
Retry failed after 6 tries. Retry settings can be adjusted in ClientOptions.Retry. (The SSL connection could not be established, see inner exception.)
我的直觉告诉我,dotnet 应用程序需要以某种方式使用证书来访问在 docker 上运行的 azurite,但是在这方面我太菜鸟了,有没有人知道我哪里出错了?
【问题讨论】: