使用@azure/arm-containerinstance 在 ACI 上生成容器

Spawn containers on ACI using @azure/arm-containerinstance

我正在处理数据微服务。我已将此微服务 dockerized,现在我想部署它。为了实现它,我正在尝试使用 node.js.

中编写的 Azure 函数来管理 Azure 容器实例中的容器

我想测试的第一件事是在一个组中生成容器。我的想法是:

const oldConfig = await client.containerGroups.get(
    'resourceGroup',
    'resourceName'
);

const response = await client.containerGroups.createOrUpdate(
  'resourceGroup',
  'resourceName',
  {
    osType: oldConfig.osType,
    containers: [
      ...oldConfig.containers,
      {
        name: 'test',
        image: 'hello-world',
        resources: {
          requests: {
            memoryInGB: 1,
            cpu: 1,
          },
        },
      },
    ],
  }
);

我已经添加了 osType,因为文档和界面说它是必需的,但是当我这样做时,我收到错误消息“要更新 osType,您需要删除并创建组容器”。当我删除 osType 时,请求成功,但 ACI 没有改变。我无法在每个新容器上重新创建整个组,因为我希望它们处理作业并自行终止。

并非所有属性都支持更新。详情见下方:

Not all container group properties can be updated. For example, to change the restart policy of a container, you must first delete the container group, then create it again.

Changes to these properties require container group deletion prior to redeployment:

OS type CPU, memory, or GPU resources Restart policy Network profile

因此容器组在您更新 osType 后不会改变。您需要删除容器组并使用更改创建它。获取有关 Update.

的更多详细信息