Files
4201b08be2 [AutoPR @azure-arm-containerinstance]-generated-from-SDK Generation - JS-6410514 (#38853)
Configurations:
'specification/containerinstance/resource-manager/Microsoft.ContainerInstance/ContainerInstance/tspconfig.yaml',
API Version: 2026-06-01-preview, SDK Release Type: beta, and CommitSHA:
'1b4778de3e8c7709823e0f95bbd8c29bedeb5bdb' in SpecRepo:
'https://github.com/Azure/azure-rest-api-specs' Pipeline run:
https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6410514
Refer to
https://eng.ms/docs/products/azure-developer-experience/develop/sdk-release/sdk-release-prerequisites
to prepare for SDK release.

### Packages impacted by this PR

`@azure/arm-containerinstance`

### Issues associated with this PR


### Describe the problem that is addressed by this PR

Auto-generated SDK update for `@azure/arm-containerinstance` from
TypeSpec/emitter, targeting API version `2026-06-01-preview` (beta
release). The branch has been updated with the latest changes from the
`main` branch.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?

Auto-generated via SDK generation pipeline (build ID: 6410514).

### Are there test cases added in this PR? _(If not, why?)_

No. This is an auto-generated SDK PR.

### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

Pipeline run:
https://dev.azure.com/azure-sdk/internal/_build/results?buildId=6410514

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)

---------

Co-authored-by: Jiao Di (MSFT) <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: jeremymeng <[email protected]>
Co-authored-by: Jeremy Meng <[email protected]>
2026-06-24 13:55:12 +08:00

387 lines
14 KiB
JavaScript

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const { ContainerInstanceManagementClient } = require("@azure/arm-containerinstance");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to create or update container groups with specified configurations.
*
* @summary create or update container groups with specified configurations.
* x-ms-original-file: 2026-06-01-preview/ContainerGroupCreateConfidential.json
*/
async function confidentialContainerGroup() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ContainerInstanceManagementClient(credential, subscriptionId);
const result = await client.containerGroups.createOrUpdate("demo", "demo1", {
location: "westeurope",
confidentialComputeProperties: {
ccePolicy:
"eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19",
},
containers: [
{
name: "accdemo",
command: [],
environmentVariables: [],
image: "confiimage",
ports: [{ port: 8000 }],
resources: { requests: { cpu: 1, memoryInGB: 1.5 } },
securityContext: { capabilities: { add: ["CAP_NET_ADMIN"] }, privileged: false },
},
],
imageRegistryCredentials: [],
ipAddress: { type: "Public", ports: [{ port: 8000, protocol: "TCP" }] },
osType: "Linux",
sku: "Confidential",
});
console.log(result);
}
/**
* This sample demonstrates how to create or update container groups with specified configurations.
*
* @summary create or update container groups with specified configurations.
* x-ms-original-file: 2026-06-01-preview/ContainerGroupCreateOrUpdateStandbyPool.json
*/
async function containerGroupCreateOrUpdateWithStandbyPool() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ContainerInstanceManagementClient(credential, subscriptionId);
const result = await client.containerGroups.createOrUpdate("demo", "demo1", {
location: "west us",
containerGroupProfile: {
id: "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp",
revision: 1,
},
containers: [{ name: "demo1", configMap: { keyValuePairs: { Newkey: "value" } } }],
standbyPoolProfile: {
id: "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.StandbyPool/standbyContainerGroupPools/demopool",
},
});
console.log(result);
}
/**
* This sample demonstrates how to create or update container groups with specified configurations.
*
* @summary create or update container groups with specified configurations.
* x-ms-original-file: 2026-06-01-preview/ContainerGroupEncryptionProperties.json
*/
async function containerGroupWithEncryptionProperties() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ContainerInstanceManagementClient(credential, subscriptionId);
const result = await client.containerGroups.createOrUpdate("demo", "demo1", {
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity":
{},
},
},
location: "eastus2",
containers: [
{
name: "demo1",
command: [],
environmentVariables: [],
image: "nginx",
ports: [{ port: 80 }],
resources: { requests: { cpu: 1, memoryInGB: 1.5 } },
},
],
encryptionProperties: {
identity:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity",
keyName: "test-key",
keyVersion: "<key version>",
vaultBaseUrl: "https://testkeyvault.vault.azure.net",
},
imageRegistryCredentials: [],
ipAddress: { type: "Public", ports: [{ port: 80, protocol: "TCP" }] },
osType: "Linux",
});
console.log(result);
}
/**
* This sample demonstrates how to create or update container groups with specified configurations.
*
* @summary create or update container groups with specified configurations.
* x-ms-original-file: 2026-06-01-preview/ContainerGroupExtensions.json
*/
async function containerGroupCreateWithExtensions() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ContainerInstanceManagementClient(credential, subscriptionId);
const result = await client.containerGroups.createOrUpdate("demo", "demo1", {
location: "eastus2",
containers: [
{
name: "demo1",
command: [],
environmentVariables: [],
image: "nginx",
ports: [{ port: 80 }],
resources: { requests: { cpu: 1, memoryInGB: 1.5 } },
},
],
imageRegistryCredentials: [],
ipAddress: { type: "Private", ports: [{ port: 80, protocol: "TCP" }] },
osType: "Linux",
subnetIds: [
{
id: "/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-rg-vnet/subnets/test-subnet",
},
],
extensions: [
{
name: "kube-proxy",
extensionType: "kube-proxy",
protectedSettings: { kubeConfig: "<kubeconfig encoded string>" },
settings: { clusterCidr: "10.240.0.0/16", kubeVersion: "v1.9.10" },
version: "1.0",
},
{ name: "vk-realtime-metrics", extensionType: "realtime-metrics", version: "1.0" },
],
});
console.log(result);
}
/**
* This sample demonstrates how to create or update container groups with specified configurations.
*
* @summary create or update container groups with specified configurations.
* x-ms-original-file: 2026-06-01-preview/ContainerGroupsCreateOrUpdate.json
*/
async function containerGroupsCreateOrUpdate() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ContainerInstanceManagementClient(credential, subscriptionId);
const result = await client.containerGroups.createOrUpdate("demo", "demo1", {
identity: {
type: "SystemAssigned, UserAssigned",
userAssignedIdentities: {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name":
{},
},
},
location: "west us",
containers: [
{
name: "demo1",
command: [],
environmentVariables: [],
image: "nginx",
ports: [{ port: 80 }],
resources: { requests: { cpu: 1, gpu: { count: 1, sku: "K80" }, memoryInGB: 1.5 } },
volumeMounts: [
{ name: "volume1", mountPath: "/mnt/volume1", readOnly: false },
{ name: "volume2", mountPath: "/mnt/volume2", readOnly: false },
{ name: "volume3", mountPath: "/mnt/volume3", readOnly: true },
],
},
],
diagnostics: {
logAnalytics: {
logType: "ContainerInsights",
metadata: { "test-key": "test-metadata-value" },
workspaceId: "workspaceid",
workspaceKey: "workspaceKey",
workspaceResourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace",
},
},
dnsConfig: {
nameServers: ["1.1.1.1"],
options: "ndots:2",
searchDomains: "cluster.local svc.cluster.local",
},
imageRegistryCredentials: [],
ipAddress: {
type: "Public",
autoGeneratedDomainNameLabelScope: "Unsecure",
dnsNameLabel: "dnsnamelabel1",
ports: [{ port: 80, protocol: "TCP" }],
},
osType: "Linux",
subnetIds: [
{
id: "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]",
},
],
volumes: [
{
name: "volume1",
azureFile: {
shareName: "shareName",
storageAccountKey: "accountKey",
storageAccountName: "accountName",
},
},
{ name: "volume2", emptyDir: {} },
{
name: "volume3",
secret: { secretKey1: "SecretValue1InBase64", secretKey2: "SecretValue2InBase64" },
},
],
});
console.log(result);
}
/**
* This sample demonstrates how to create or update container groups with specified configurations.
*
* @summary create or update container groups with specified configurations.
* x-ms-original-file: 2026-06-01-preview/ContainerGroupsCreateOrUpdateSecretReference.json
*/
async function containerGroupsCreateOrUpdateSecretReference() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ContainerInstanceManagementClient(credential, subscriptionId);
const result = await client.containerGroups.createOrUpdate("demo", "demo1", {
identity: {
type: "UserAssigned",
userAssignedIdentities: {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name":
{},
},
},
location: "west us",
containers: [
{
name: "demo1",
command: [],
environmentVariables: [{ name: "envSecret", secureValueReference: "envSecretRef" }],
image: "privateRegistryImage",
ports: [{ port: 80 }],
resources: { requests: { cpu: 1, gpu: { count: 1, sku: "K80" }, memoryInGB: 1.5 } },
volumeMounts: [
{ name: "volume1", mountPath: "/mnt/volume1", readOnly: false },
{ name: "volume2", mountPath: "/mnt/volume2", readOnly: false },
{ name: "volume3", mountPath: "/mnt/volume3", readOnly: true },
],
},
],
diagnostics: {
logAnalytics: {
logType: "ContainerInsights",
metadata: { "test-key": "test-metadata-value" },
workspaceId: "workspaceid",
workspaceKey: "workspaceKey",
workspaceResourceId:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace",
},
},
dnsConfig: {
nameServers: ["1.1.1.1"],
options: "ndots:2",
searchDomains: "cluster.local svc.cluster.local",
},
imageRegistryCredentials: [
{
passwordReference: "privateRegistryKeyRef",
server: "demoregistry.azurecr.io",
username: "registryUserName",
},
],
ipAddress: {
type: "Public",
autoGeneratedDomainNameLabelScope: "Unsecure",
dnsNameLabel: "dnsnamelabel1",
ports: [{ port: 80, protocol: "TCP" }],
},
osType: "Linux",
secretReferences: [
{
name: "envSecretRef",
identity:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
secretReferenceUri: "https://keyvaultname.vault.azure.net/secrets/envSecret",
},
{
name: "accountKeyRef",
identity:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
secretReferenceUri: "https://keyvaultname.vault.azure.net/secrets/accountKey",
},
{
name: "volumeSecretRef",
identity:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
secretReferenceUri: "https://keyvaultname.vault.azure.net/secrets/volumeSecret",
},
{
name: "privateRegistryKeyRef",
identity:
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
secretReferenceUri: "https://keyvaultname.vault.azure.net/secrets/privateRegistryKey",
},
],
subnetIds: [
{
id: "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]",
},
],
volumes: [
{
name: "volume1",
azureFile: {
shareName: "shareName",
storageAccountKeyReference: "accountKeyRef",
storageAccountName: "accountName",
},
},
{ name: "volume2", emptyDir: {} },
{
name: "volume3",
secret: { secretKey1: "SecretValue1InBase64" },
secretReference: { secretKey2: "volumeSecretRef" },
},
],
});
console.log(result);
}
/**
* This sample demonstrates how to create or update container groups with specified configurations.
*
* @summary create or update container groups with specified configurations.
* x-ms-original-file: 2026-06-01-preview/ContainerGroupsCreatePriority.json
*/
async function containerGroupsCreateWithPriority() {
const credential = new DefaultAzureCredential();
const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new ContainerInstanceManagementClient(credential, subscriptionId);
const result = await client.containerGroups.createOrUpdate("demo", "demo1", {
location: "eastus",
containers: [
{
name: "test-container-001",
command: ["/bin/sh", "-c", "sleep 10"],
image: "alpine:latest",
resources: { requests: { cpu: 1, memoryInGB: 1 } },
},
],
osType: "Linux",
priority: "Spot",
restartPolicy: "Never",
sku: "Standard",
});
console.log(result);
}
async function main() {
await confidentialContainerGroup();
await containerGroupCreateOrUpdateWithStandbyPool();
await containerGroupWithEncryptionProperties();
await containerGroupCreateWithExtensions();
await containerGroupsCreateOrUpdate();
await containerGroupsCreateOrUpdateSecretReference();
await containerGroupsCreateWithPriority();
}
main().catch(console.error);