使用虚拟网络部署容器实例的步骤

Steps for deployment of Container Instance with Virtual Network

我想自动部署虚拟网络(与另一个网络对等互连)和连接到该网络的容器实例。 我只想确认我会执行正确的步骤。我将使用 Azure REST API.

  1. 使用子网部署虚拟网络
  2. 创建与其他虚拟网络的对等互连
  3. 创建网络配置文件
  4. 使用创建的网络配置文件部署 Container。

第 3 步对我来说有点奇怪,因为它与我在 Azure 门户中所做的不同。在门户中,我只是 select 我希望我的容器连接到的虚拟网络。查看 MSDN 文档,在我看来,REST API 要求我首先创建该网络配置文件。我说得对吗?

当您使用 az container create 部署容器时,az cli 将在后台为您创建网络配置文件。

这可能就是您之前可能没有看到明确创建网络配置文件的原因。

A network profile is a network configuration template for Azure resources. It specifies certain network properties for the resource, for example, the subnet into which it should be deployed. When you first use the az container create command to deploy a container group to a subnet (and thus a virtual network), Azure creates a network profile for you. You can then use that network profile for future deployments to the subnet.

https://docs.microsoft.com/en-us/azure/container-instances/container-instances-vnet#network-profile

你的脚步看起来不错。