【发布时间】:2019-09-10 02:37:44
【问题描述】:
我正在尝试创建一个 Azure 容器实例并通过 REST API 安装一个文件存储卷,但我收到了 400 响应。
我能够创建容器并使其保持运行,但是当我添加卷部分时,它返回 400 响应(错误请求)而无需进一步解释
这是我发送到 REST 端点的 JSON 负载:
{
"id": "/subscriptions/111111111/resourceGroups/OraResourceGroup/providers/Microsoft.ContainerInstance/containerGroups/solver",
"location": "West Europe",
"name": "solver",
"properties": {
"volumes": [
{
"azureFile": {
"shareName": "orafileshare",
"storageAccountKey": "somekey",
"storageAccountName": "myaccountname"
},
"name": "Volume1"
}
],
"containers": [
{
"name": "solver",
"properties": {
"command": [],
"environmentVariables": [],
"image": "acraccount/solver:v1",
"ports": [
{
"port": 12345
}
],
"resources": {
"requests": {
"cpu": 1.0,
"memoryInGB": 1.5
}
},
"volumeMounts": [
{
"name": "Volume1",
"mountPath": "/mountFolder"
}
]
}
}
],
"imageRegistryCredentials": [
{
"password": "123123123213123",
"server": "acr.server.io",
"username": "acrOra"
}
],
"ipAddress": {
"ports": [
{
"protocol": "TCP",
"port": 12345
}
],
"type": "Public"
},
"osType": "Linux",
"restartPolicy": "Always"
},
"type": "Microsoft.ContainerInstance/containerGroups"
}
预期结果是 200 或 201 响应,容器应该出现在我的 Azure 门户仪表板上,但实际响应是 400。
【问题讨论】:
-
mountPath的文档是“容器内应安装卷的路径”,但您提供了文件共享的 URL。请参阅文档中的 example request body。 -
@nlawalker 我将 mountPath 更改为 /mountFolder 但仍然是错误的请求
标签: c# azure containers azure-container-instances