无法使用@azure/arm容器实例创建容器组



我正试图在不使用azure javascript包@azure/arm-containerinstance的情况下创建容器组,但关于它的文档很少。这是我实现的代码:

const name = "SOMECONTAINERNAME";
const image = "someregisterylink.com/somename/someimage:latest-sometag";
const port = 6901;
const environmentVariables = {
VAR1: "SOMEVAR",
VAR2: "SOMEVAR"
};
const containerResourceRequests = {
memoryInGB:1.5,
cpu:1
};
const containerResourceRequirements = {
requests:containerResourceRequests
}
const container = {
image: image,
resources: containerResourceRequirements,
command: ['/bin/bash','-c','echo $PATH'],
ports: [{port: port}],
environmentVariables: environmentVariables
};
const cgroup_os_type = "Linux";
const cgroup_ip_address = {
type: 'public',
ports: [{protocol: "TCP", port: port}]
}
const image_registry_credentials=null;
const cgroup = {
location: 'westus',
containers: [container],
os_type:cgroup_os_type,
ip_address: cgroup_ip_address
//image_registry_credentials: image_registry_credentials
}
var response = await azclient.containerGroups.beginCreateOrUpdate(
resourceGroupName=config.resourceGroup,
containerGroupName=name,
cgroup);
console.log(response);

响应非常详细,但没有显示任何错误,并且在azure资源组上没有创建任何内容。

您可以参考此Github源代码,使用用于JavaScript的Azure ContainerInstanceManagement客户端库创建容器组。

您需要的先决条件很少。

安装@azure/arm容器实例包

使用npm:为JavaScript安装Azure ContainerInstanceManagement客户端库

当前支持的环境

  • Node.js的LTS版本
  • Safari、Chrome、Edge和Firefox的最新版本

有关详细信息,请参阅数据文件

最新更新