亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 REST api 將文件存儲卷掛載到 Azure 容器實例

如何使用 REST api 將文件存儲卷掛載到 Azure 容器實例

C#
楊魅力 2022-12-24 10:16:45
我正在嘗試創建 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。
查看完整描述

1 回答

?
翻翻過去那場雪

TA貢獻2065條經驗 獲得超14個贊

此更正有 2 個問題。我也收到了 400 個錯誤的請求,但后來更正了它,我能夠成功運行它。

  1. 卷名,不允許大寫字母。

Change "Volume1" to "volume1"

參考錯誤:

{"error":{"code":"InvalidVolumeName","message":"The volume name 'Volume1' is invalid. The volume name must match the regex '[a-z0-9]([-a-z0-9]*[a-z0-9])?' (e.g. 'my-name')."}}

  1. Sku 不是有效屬性,請將其刪除

    {"error":{"code":"InvalidRequestContent","message":"The request content was invalid and could not be deserialized: 'Could not find member 'sku' on object of type 'ComputeResources'. Path 'properties.containers[0].properties.resources.requests.sku', line 32, position 22.'."}}

    參考https://learn.microsoft.com/en-us/rest/api/container-instances/containergroups/createorupdate#resourcerequests

示例配置

{

  "id": "/subscriptions/xxxx/resourceGroups/teststoragerest/providers/Microsoft.ContainerInstance/containerGroups/solver",

  "location": "West Europe",

  "name": "demo1forrahul",

  "properties": {

    "volumes": [

      {

        "azureFile": {

          "shareName": "testfilestorage",

          "storageAccountKey": "xxxx",

          "storageAccountName": "xxxxxx"

        },

        "name": "volume1"

      }

    ],

    "containers": [

      {

        "name": "demo1forrahul",

        "properties": {

          "command": [],

          "environmentVariables": [],

          "image": "nginx",

          "ports": [

            {

              "port": 80

            }

          ],

          "resources": {

            "requests": {

              "cpu": 1.0,

              "memoryInGB": 1.5

            }

          },

          "volumeMounts": [

            {

              "name": "volume1",

              "mountPath": "/testfolder"

            }

          ]

        }

      }

    ],

    "imageRegistryCredentials": [],

    "ipAddress": {

      "ports": [

        {

          "protocol": "TCP",

          "port": 80

        }

      ],

      "type": "Public"

    },

    "osType": "Linux",

    "restartPolicy": "Always"

  },

  "type": "Microsoft.ContainerInstance/containerGroups"

}


查看完整回答
反對 回復 2022-12-24
  • 1 回答
  • 0 關注
  • 77 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號