Create or update container groups with specified configurations.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}?api-version=2026-07-01
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
containerGroupName
|
path |
True
|
string
|
The name of the container group.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
The name of the resource group. The name is case insensitive.
|
|
subscriptionId
|
path |
True
|
string
(uuid)
|
The ID of the target subscription. The value must be an UUID.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
Request Body
| Name |
Required |
Type |
Description |
|
properties.containers
|
True
|
Container[]
|
The containers within the container group.
|
|
identity
|
|
ContainerGroupIdentity
|
The identity of the container group, if configured.
|
|
location
|
|
string
|
The resource location of the container group.
|
|
properties.confidentialComputeProperties
|
|
ConfidentialComputeProperties
|
The properties for confidential container group
|
|
properties.containerGroupProfile
|
|
ContainerGroupProfileReferenceDefinition
|
The reference container group profile properties.
|
|
properties.diagnostics
|
|
ContainerGroupDiagnostics
|
The diagnostic information for a container group.
|
|
properties.dnsConfig
|
|
DnsConfiguration
|
The DNS config information for a container group.
|
|
properties.encryptionProperties
|
|
EncryptionProperties
|
The encryption properties for a container group.
|
|
properties.extensions
|
|
DeploymentExtensionSpec[]
|
extensions used by virtual kubelet
|
|
properties.identityAcls
|
|
IdentityAcls
|
The access control levels of the identities.
|
|
properties.imageRegistryCredentials
|
|
ImageRegistryCredential[]
|
The image registry credentials by which the container group is created from.
|
|
properties.initContainers
|
|
InitContainerDefinition[]
|
The init containers for a container group.
|
|
properties.ipAddress
|
|
IpAddress
|
The IP address type of the container group.
|
|
properties.osType
|
|
OperatingSystemTypes
|
The operating system type required by the containers in the container group.
|
|
properties.priority
|
|
ContainerGroupPriority
|
The priority of the container group.
|
|
properties.restartPolicy
|
|
ContainerGroupRestartPolicy
|
Restart policy for all containers within the container group.
Always Always restart
OnFailure Restart on failure
Never Never restart
|
|
properties.secretReferences
|
|
SecretReference[]
|
The secret references that will be referenced within the container group.
|
|
properties.sku
|
|
ContainerGroupSku
|
The SKU for a container group.
|
|
properties.standbyPoolProfile
|
|
StandbyPoolProfileDefinition
|
The reference standby pool profile properties.
|
|
properties.subnetIds
|
|
ContainerGroupSubnetId[]
|
The subnet resource IDs for a container group.
|
|
properties.volumes
|
|
Volume[]
|
The list of volumes that can be mounted by containers in this container group.
|
|
tags
|
|
object
|
The resource tags.
|
|
zones
|
|
string[]
|
The availability zones.
|
Responses
| Name |
Type |
Description |
|
200 OK
|
ContainerGroup
|
Resource 'ContainerGroup' update operation succeeded
|
|
201 Created
|
ContainerGroup
|
Resource 'ContainerGroup' create operation succeeded
Headers
- Location: string
- Retry-After: integer
|
|
Other Status Codes
|
CloudError
|
An unexpected error response.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name |
Description |
|
user_impersonation
|
impersonate your user account
|
Examples
ConfidentialContainerGroup
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1?api-version=2026-07-01
{
"location": "westeurope",
"properties": {
"confidentialComputeProperties": {
"ccePolicy": "eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19"
},
"containers": [
{
"name": "accdemo",
"properties": {
"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"
}
}
import com.azure.resourcemanager.containerinstance.fluent.models.ContainerGroupInner;
import com.azure.resourcemanager.containerinstance.models.ConfidentialComputeProperties;
import com.azure.resourcemanager.containerinstance.models.Container;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIpAddressType;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupNetworkProtocol;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupSku;
import com.azure.resourcemanager.containerinstance.models.ContainerPort;
import com.azure.resourcemanager.containerinstance.models.IpAddress;
import com.azure.resourcemanager.containerinstance.models.OperatingSystemTypes;
import com.azure.resourcemanager.containerinstance.models.Port;
import com.azure.resourcemanager.containerinstance.models.ResourceRequests;
import com.azure.resourcemanager.containerinstance.models.ResourceRequirements;
import com.azure.resourcemanager.containerinstance.models.SecurityContextCapabilitiesDefinition;
import com.azure.resourcemanager.containerinstance.models.SecurityContextDefinition;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ContainerGroups CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/ContainerGroupCreateConfidential.json
*/
/**
* Sample code: ConfidentialContainerGroup.
*
* @param manager Entry point to ContainerInstanceManager.
*/
public static void
confidentialContainerGroup(com.azure.resourcemanager.containerinstance.ContainerInstanceManager manager) {
manager.serviceClient().getContainerGroups().createOrUpdate("demo", "demo1", new ContainerGroupInner()
.withLocation("westeurope")
.withContainers(Arrays.asList(new Container().withName("accdemo").withImage("confiimage")
.withCommand(Arrays.asList()).withPorts(Arrays.asList(new ContainerPort().withPort(8000)))
.withEnvironmentVariables(Arrays.asList())
.withResources(
new ResourceRequirements().withRequests(new ResourceRequests().withMemoryInGB(1.5).withCpu(1.0)))
.withSecurityContext(new SecurityContextDefinition().withPrivileged(false).withCapabilities(
new SecurityContextCapabilitiesDefinition().withAdd(Arrays.asList("CAP_NET_ADMIN"))))))
.withImageRegistryCredentials(Arrays.asList())
.withIpAddress(new IpAddress()
.withPorts(Arrays.asList(new Port().withProtocol(ContainerGroupNetworkProtocol.TCP).withPort(8000)))
.withType(ContainerGroupIpAddressType.PUBLIC))
.withOsType(OperatingSystemTypes.LINUX).withSku(ContainerGroupSku.CONFIDENTIAL)
.withConfidentialComputeProperties(new ConfidentialComputeProperties().withCcePolicy(
"eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerinstance
# USAGE
python container_group_create_confidential.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerInstanceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.container_groups.begin_create_or_update(
resource_group_name="demo",
container_group_name="demo1",
container_group={
"location": "westeurope",
"properties": {
"confidentialComputeProperties": {
"ccePolicy": "eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19"
},
"containers": [
{
"name": "accdemo",
"properties": {
"command": [],
"environmentVariables": [],
"image": "confiimage",
"ports": [{"port": 8000}],
"resources": {"requests": {"cpu": 1, "memoryInGB": 1.5}},
"securityContext": {"capabilities": {"add": ["CAP_NET_ADMIN"]}, "privileged": False},
},
}
],
"imageRegistryCredentials": [],
"ipAddress": {"ports": [{"port": 8000, "protocol": "TCP"}], "type": "Public"},
"osType": "Linux",
"sku": "Confidential",
},
},
).result()
print(response)
# x-ms-original-file: 2026-07-01/ContainerGroupCreateConfidential.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerinstance_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v3"
)
// Generated from example definition: 2026-07-01/ContainerGroupCreateConfidential.json
func ExampleContainerGroupsClient_BeginCreateOrUpdate_confidentialContainerGroup() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerinstance.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{
Location: to.Ptr("westeurope"),
Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
ConfidentialComputeProperties: &armcontainerinstance.ConfidentialComputeProperties{
CcePolicy: to.Ptr("eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19"),
},
Containers: []*armcontainerinstance.Container{
{
Name: to.Ptr("accdemo"),
Properties: &armcontainerinstance.ContainerProperties{
Command: []*string{},
EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{},
Image: to.Ptr("confiimage"),
Ports: []*armcontainerinstance.ContainerPort{
{
Port: to.Ptr[int32](8000),
},
},
Resources: &armcontainerinstance.ResourceRequirements{
Requests: &armcontainerinstance.ResourceRequests{
CPU: to.Ptr[float64](1),
MemoryInGB: to.Ptr[float64](1.5),
},
},
SecurityContext: &armcontainerinstance.SecurityContextDefinition{
Capabilities: &armcontainerinstance.SecurityContextCapabilitiesDefinition{
Add: []*string{
to.Ptr("CAP_NET_ADMIN"),
},
},
Privileged: to.Ptr(false),
},
},
},
},
ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{},
IPAddress: &armcontainerinstance.IPAddress{
Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
Ports: []*armcontainerinstance.Port{
{
Port: to.Ptr[int32](8000),
Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
},
},
},
OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUConfidential),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to poll the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcontainerinstance.ContainerGroupsClientCreateOrUpdateResponse{
// ContainerGroup: armcontainerinstance.ContainerGroup{
// Name: to.Ptr("demo1"),
// Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1"),
// Location: to.Ptr("westeurope"),
// Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
// ConfidentialComputeProperties: &armcontainerinstance.ConfidentialComputeProperties{
// CcePolicy: to.Ptr("eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19"),
// },
// Containers: []*armcontainerinstance.Container{
// {
// Name: to.Ptr("accdemo"),
// Properties: &armcontainerinstance.ContainerProperties{
// Command: []*string{
// },
// EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{
// },
// Image: to.Ptr("confiimage"),
// Ports: []*armcontainerinstance.ContainerPort{
// {
// Port: to.Ptr[int32](8000),
// },
// },
// Resources: &armcontainerinstance.ResourceRequirements{
// Requests: &armcontainerinstance.ResourceRequests{
// CPU: to.Ptr[float64](1),
// MemoryInGB: to.Ptr[float64](1.5),
// },
// },
// SecurityContext: &armcontainerinstance.SecurityContextDefinition{
// Capabilities: &armcontainerinstance.SecurityContextCapabilitiesDefinition{
// Add: []*string{
// to.Ptr("CAP_NET_ADMIN"),
// },
// },
// Privileged: to.Ptr(false),
// },
// },
// },
// },
// ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{
// },
// InitContainers: []*armcontainerinstance.InitContainerDefinition{
// },
// InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{
// Events: []*armcontainerinstance.Event{
// },
// State: to.Ptr("Running"),
// },
// IPAddress: &armcontainerinstance.IPAddress{
// Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
// Ports: []*armcontainerinstance.Port{
// {
// Port: to.Ptr[int32](8000),
// Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
// },
// },
// },
// IsCreatedFromStandbyPool: to.Ptr(false),
// OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUConfidential),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
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-07-01/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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "westeurope",
"properties": {
"confidentialComputeProperties": {
"ccePolicy": "eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19"
},
"containers": [
{
"name": "accdemo",
"properties": {
"command": [],
"environmentVariables": [],
"image": "confiimage",
"ports": [
{
"port": 8000
}
],
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1.5
}
},
"securityContext": {
"capabilities": {
"add": [
"CAP_NET_ADMIN"
]
},
"privileged": false
}
}
}
],
"imageRegistryCredentials": [],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Running"
},
"ipAddress": {
"type": "Public",
"ports": [
{
"port": 8000,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Succeeded",
"sku": "Confidential"
}
}
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "westeurope",
"properties": {
"confidentialComputeProperties": {
"ccePolicy": "eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19"
},
"containers": [
{
"name": "accdemo",
"properties": {
"command": [],
"environmentVariables": [],
"image": "confiimage",
"ports": [
{
"port": 8000
}
],
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1.5
}
},
"securityContext": {
"capabilities": {
"add": [
"CAP_NET_ADMIN"
]
},
"privileged": false
}
}
}
],
"imageRegistryCredentials": [],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Running"
},
"ipAddress": {
"type": "Public",
"ports": [
{
"port": 8000,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Succeeded",
"sku": "Confidential"
}
}
ContainerGroupCreateOrUpdateWithStandbyPool
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1?api-version=2026-07-01
{
"location": "west us",
"properties": {
"containerGroupProfile": {
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp",
"revision": 1
},
"containers": [
{
"name": "demo1",
"properties": {
"configMap": {
"keyValuePairs": {
"Newkey": "value"
}
}
}
}
],
"standbyPoolProfile": {
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.StandbyPool/standbyContainerGroupPools/demopool"
}
}
}
import com.azure.resourcemanager.containerinstance.fluent.models.ContainerGroupInner;
import com.azure.resourcemanager.containerinstance.models.ConfigMap;
import com.azure.resourcemanager.containerinstance.models.Container;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupProfileReferenceDefinition;
import com.azure.resourcemanager.containerinstance.models.StandbyPoolProfileDefinition;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ContainerGroups CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/ContainerGroupCreateOrUpdateStandbyPool.json
*/
/**
* Sample code: ContainerGroupCreateOrUpdateWithStandbyPool.
*
* @param manager Entry point to ContainerInstanceManager.
*/
public static void containerGroupCreateOrUpdateWithStandbyPool(
com.azure.resourcemanager.containerinstance.ContainerInstanceManager manager) {
manager.serviceClient().getContainerGroups().createOrUpdate("demo", "demo1", new ContainerGroupInner()
.withLocation("west us")
.withContainers(Arrays.asList(new Container().withName("demo1")
.withConfigMap(new ConfigMap().withKeyValuePairs(mapOf("Newkey", "fakeTokenPlaceholder")))))
.withContainerGroupProfile(new ContainerGroupProfileReferenceDefinition().withId(
"/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp")
.withRevision(1))
.withStandbyPoolProfile(new StandbyPoolProfileDefinition().withId(
"/subscriptions/subid/resourceGroups/demo/providers/Microsoft.StandbyPool/standbyContainerGroupPools/demopool")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerinstance
# USAGE
python container_group_create_or_update_standby_pool.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerInstanceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.container_groups.begin_create_or_update(
resource_group_name="demo",
container_group_name="demo1",
container_group={
"location": "west us",
"properties": {
"containerGroupProfile": {
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp",
"revision": 1,
},
"containers": [{"name": "demo1", "properties": {"configMap": {"keyValuePairs": {"Newkey": "value"}}}}],
"standbyPoolProfile": {
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.StandbyPool/standbyContainerGroupPools/demopool"
},
},
},
).result()
print(response)
# x-ms-original-file: 2026-07-01/ContainerGroupCreateOrUpdateStandbyPool.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerinstance_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v3"
)
// Generated from example definition: 2026-07-01/ContainerGroupCreateOrUpdateStandbyPool.json
func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupCreateOrUpdateWithStandbyPool() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerinstance.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{
Location: to.Ptr("west us"),
Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
ContainerGroupProfile: &armcontainerinstance.ContainerGroupProfileReferenceDefinition{
ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp"),
Revision: to.Ptr[int32](1),
},
Containers: []*armcontainerinstance.Container{
{
Name: to.Ptr("demo1"),
Properties: &armcontainerinstance.ContainerProperties{
ConfigMap: &armcontainerinstance.ConfigMap{
KeyValuePairs: map[string]*string{
"Newkey": to.Ptr("value"),
},
},
},
},
},
StandbyPoolProfile: &armcontainerinstance.StandbyPoolProfileDefinition{
ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.StandbyPool/standbyContainerGroupPools/demopool"),
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to poll the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcontainerinstance.ContainerGroupsClientCreateOrUpdateResponse{
// ContainerGroup: armcontainerinstance.ContainerGroup{
// Name: to.Ptr("demo1"),
// Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"),
// Location: to.Ptr("eastus2"),
// Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
// ContainerGroupProfile: &armcontainerinstance.ContainerGroupProfileReferenceDefinition{
// ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp"),
// Revision: to.Ptr[int32](1),
// },
// Containers: []*armcontainerinstance.Container{
// {
// Name: to.Ptr("demo1"),
// Properties: &armcontainerinstance.ContainerProperties{
// Command: []*string{
// },
// ConfigMap: &armcontainerinstance.ConfigMap{
// KeyValuePairs: map[string]*string{
// "Newkey": to.Ptr("value"),
// },
// },
// EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{
// },
// Image: to.Ptr("nginx"),
// Ports: []*armcontainerinstance.ContainerPort{
// {
// Port: to.Ptr[int32](80),
// },
// },
// Resources: &armcontainerinstance.ResourceRequirements{
// Requests: &armcontainerinstance.ResourceRequests{
// CPU: to.Ptr[float64](1),
// MemoryInGB: to.Ptr[float64](1.5),
// },
// },
// },
// },
// },
// ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{
// },
// InitContainers: []*armcontainerinstance.InitContainerDefinition{
// },
// InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{
// Events: []*armcontainerinstance.Event{
// },
// State: to.Ptr("Running"),
// },
// IsCreatedFromStandbyPool: to.Ptr(true),
// OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
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-07-01/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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "eastus2",
"properties": {
"containerGroupProfile": {
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp",
"revision": 1
},
"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"configMap": {
"keyValuePairs": {
"Newkey": "value"
}
},
"environmentVariables": [],
"image": "nginx",
"ports": [
{
"port": 80
}
],
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1.5
}
}
}
}
],
"imageRegistryCredentials": [],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Running"
},
"isCreatedFromStandbyPool": true,
"osType": "Linux",
"provisioningState": "Succeeded",
"sku": "Standard"
}
}
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "eastus2",
"properties": {
"containerGroupProfile": {
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp",
"revision": 1
},
"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"configMap": {
"keyValuePairs": {
"Newkey": "value"
}
},
"environmentVariables": [],
"image": "nginx",
"ports": [
{
"port": 80
}
],
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1.5
}
}
}
}
],
"imageRegistryCredentials": [],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Running"
},
"isCreatedFromStandbyPool": true,
"osType": "Linux",
"provisioningState": "Succeeded",
"sku": "Standard"
}
}
ContainerGroupCreateWithExtensions
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1?api-version=2026-07-01
{
"location": "eastus2",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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",
"properties": {
"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",
"properties": {
"extensionType": "realtime-metrics",
"version": "1.0"
}
}
]
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.containerinstance.fluent.models.ContainerGroupInner;
import com.azure.resourcemanager.containerinstance.models.Container;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIpAddressType;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupNetworkProtocol;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupSubnetId;
import com.azure.resourcemanager.containerinstance.models.ContainerPort;
import com.azure.resourcemanager.containerinstance.models.DeploymentExtensionSpec;
import com.azure.resourcemanager.containerinstance.models.IpAddress;
import com.azure.resourcemanager.containerinstance.models.OperatingSystemTypes;
import com.azure.resourcemanager.containerinstance.models.Port;
import com.azure.resourcemanager.containerinstance.models.ResourceRequests;
import com.azure.resourcemanager.containerinstance.models.ResourceRequirements;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ContainerGroups CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/ContainerGroupExtensions.json
*/
/**
* Sample code: ContainerGroupCreateWithExtensions.
*
* @param manager Entry point to ContainerInstanceManager.
*/
public static void containerGroupCreateWithExtensions(
com.azure.resourcemanager.containerinstance.ContainerInstanceManager manager) throws IOException {
manager.serviceClient().getContainerGroups().createOrUpdate("demo", "demo1", new ContainerGroupInner()
.withLocation("eastus2")
.withContainers(Arrays.asList(new Container().withName("demo1").withImage("nginx")
.withCommand(Arrays.asList()).withPorts(Arrays.asList(new ContainerPort().withPort(80)))
.withEnvironmentVariables(Arrays.asList()).withResources(
new ResourceRequirements().withRequests(new ResourceRequests().withMemoryInGB(1.5).withCpu(1.0)))))
.withImageRegistryCredentials(Arrays.asList())
.withIpAddress(new IpAddress()
.withPorts(Arrays.asList(new Port().withProtocol(ContainerGroupNetworkProtocol.TCP).withPort(80)))
.withType(ContainerGroupIpAddressType.PRIVATE))
.withOsType(OperatingSystemTypes.LINUX)
.withSubnetIds(Arrays.asList(new ContainerGroupSubnetId().withId(
"/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-rg-vnet/subnets/test-subnet")))
.withExtensions(Arrays.asList(
new DeploymentExtensionSpec().withName("kube-proxy").withExtensionType("kube-proxy").withVersion("1.0")
.withSettings(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize(
"{\"clusterCidr\":\"10.240.0.0/16\",\"kubeVersion\":\"v1.9.10\"}", Object.class,
SerializerEncoding.JSON))
.withProtectedSettings(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize(
"{\"kubeConfig\":\"<kubeconfig encoded string>\"}", Object.class, SerializerEncoding.JSON)),
new DeploymentExtensionSpec().withName("vk-realtime-metrics").withExtensionType("realtime-metrics")
.withVersion("1.0"))),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerinstance
# USAGE
python container_group_extensions.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerInstanceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.container_groups.begin_create_or_update(
resource_group_name="demo",
container_group_name="demo1",
container_group={
"location": "eastus2",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"environmentVariables": [],
"image": "nginx",
"ports": [{"port": 80}],
"resources": {"requests": {"cpu": 1, "memoryInGB": 1.5}},
},
}
],
"extensions": [
{
"name": "kube-proxy",
"properties": {
"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",
"properties": {"extensionType": "realtime-metrics", "version": "1.0"},
},
],
"imageRegistryCredentials": [],
"ipAddress": {"ports": [{"port": 80, "protocol": "TCP"}], "type": "Private"},
"osType": "Linux",
"subnetIds": [
{
"id": "/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-rg-vnet/subnets/test-subnet"
}
],
},
},
).result()
print(response)
# x-ms-original-file: 2026-07-01/ContainerGroupExtensions.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerinstance_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v3"
)
// Generated from example definition: 2026-07-01/ContainerGroupExtensions.json
func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupCreateWithExtensions() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerinstance.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{
Location: to.Ptr("eastus2"),
Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
Containers: []*armcontainerinstance.Container{
{
Name: to.Ptr("demo1"),
Properties: &armcontainerinstance.ContainerProperties{
Command: []*string{},
EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{},
Image: to.Ptr("nginx"),
Ports: []*armcontainerinstance.ContainerPort{
{
Port: to.Ptr[int32](80),
},
},
Resources: &armcontainerinstance.ResourceRequirements{
Requests: &armcontainerinstance.ResourceRequests{
CPU: to.Ptr[float64](1),
MemoryInGB: to.Ptr[float64](1.5),
},
},
},
},
},
ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{},
IPAddress: &armcontainerinstance.IPAddress{
Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePrivate),
Ports: []*armcontainerinstance.Port{
{
Port: to.Ptr[int32](80),
Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
},
},
},
OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
SubnetIDs: []*armcontainerinstance.ContainerGroupSubnetID{
{
ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-rg-vnet/subnets/test-subnet"),
},
},
Extensions: []*armcontainerinstance.DeploymentExtensionSpec{
{
Name: to.Ptr("kube-proxy"),
Properties: &armcontainerinstance.DeploymentExtensionSpecProperties{
ExtensionType: to.Ptr("kube-proxy"),
ProtectedSettings: map[string]any{
"kubeConfig": "<kubeconfig encoded string>",
},
Settings: map[string]any{
"clusterCidr": "10.240.0.0/16",
"kubeVersion": "v1.9.10",
},
Version: to.Ptr("1.0"),
},
},
{
Name: to.Ptr("vk-realtime-metrics"),
Properties: &armcontainerinstance.DeploymentExtensionSpecProperties{
ExtensionType: to.Ptr("realtime-metrics"),
Version: to.Ptr("1.0"),
},
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to poll the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcontainerinstance.ContainerGroupsClientCreateOrUpdateResponse{
// ContainerGroup: armcontainerinstance.ContainerGroup{
// Name: to.Ptr("demo1"),
// Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1"),
// Location: to.Ptr("eastus2"),
// Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
// Containers: []*armcontainerinstance.Container{
// {
// Name: to.Ptr("demo1"),
// Properties: &armcontainerinstance.ContainerProperties{
// Command: []*string{
// },
// EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{
// },
// Image: to.Ptr("nginx"),
// Ports: []*armcontainerinstance.ContainerPort{
// {
// Port: to.Ptr[int32](80),
// },
// },
// Resources: &armcontainerinstance.ResourceRequirements{
// Requests: &armcontainerinstance.ResourceRequests{
// CPU: to.Ptr[float64](1),
// MemoryInGB: to.Ptr[float64](1.5),
// },
// },
// },
// },
// },
// ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{
// },
// InitContainers: []*armcontainerinstance.InitContainerDefinition{
// },
// InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{
// Events: []*armcontainerinstance.Event{
// },
// State: to.Ptr("Pending"),
// },
// IsCreatedFromStandbyPool: to.Ptr(false),
// OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
// ProvisioningState: to.Ptr("Pending"),
// SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard),
// SubnetIDs: []*armcontainerinstance.ContainerGroupSubnetID{
// {
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-rg-vnet/subnets/test-subnet"),
// },
// },
// Extensions: []*armcontainerinstance.DeploymentExtensionSpec{
// {
// Name: to.Ptr("kube-proxy"),
// Properties: &armcontainerinstance.DeploymentExtensionSpecProperties{
// ExtensionType: to.Ptr("kube-proxy"),
// Settings: map[string]any{
// "clusterCidr": "10.240.0.0/16",
// "kubeVersion": "v1.9.10",
// },
// Version: to.Ptr("1.0"),
// },
// },
// {
// Name: to.Ptr("vk-realtime-metrics"),
// Properties: &armcontainerinstance.DeploymentExtensionSpecProperties{
// ExtensionType: to.Ptr("realtime-metrics"),
// Version: to.Ptr("1.0"),
// },
// },
// },
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
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-07-01/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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "eastus2",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"environmentVariables": [],
"image": "nginx",
"ports": [
{
"port": 80
}
],
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1.5
}
}
}
}
],
"imageRegistryCredentials": [],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Pending"
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Pending",
"sku": "Standard",
"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",
"properties": {
"extensionType": "kube-proxy",
"settings": {
"clusterCidr": "10.240.0.0/16",
"kubeVersion": "v1.9.10"
},
"version": "1.0"
}
},
{
"name": "vk-realtime-metrics",
"properties": {
"extensionType": "realtime-metrics",
"version": "1.0"
}
}
]
}
}
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "eastus2",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"environmentVariables": [],
"image": "nginx",
"ports": [
{
"port": 80
}
],
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1.5
}
}
}
}
],
"imageRegistryCredentials": [],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Running"
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Pending",
"sku": "Standard",
"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",
"properties": {
"extensionType": "kube-proxy",
"settings": {
"clusterCidr": "10.240.0.0/16",
"kubeVersion": "v1.9.10"
},
"version": "1.0"
}
},
{
"name": "vk-realtime-metrics",
"properties": {
"extensionType": "realtime-metrics",
"version": "1.0"
}
}
]
}
}
ContainerGroupsCreateOrUpdate
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1?api-version=2026-07-01
{
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {}
}
},
"location": "west us",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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"
}
}
]
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.containerinstance.fluent.models.ContainerGroupInner;
import com.azure.resourcemanager.containerinstance.models.AzureFileVolume;
import com.azure.resourcemanager.containerinstance.models.Container;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupDiagnostics;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIdentity;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIdentityUserAssignedIdentities;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIpAddressType;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupNetworkProtocol;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupSubnetId;
import com.azure.resourcemanager.containerinstance.models.ContainerPort;
import com.azure.resourcemanager.containerinstance.models.DnsConfiguration;
import com.azure.resourcemanager.containerinstance.models.DnsNameLabelReusePolicy;
import com.azure.resourcemanager.containerinstance.models.GpuResource;
import com.azure.resourcemanager.containerinstance.models.GpuSku;
import com.azure.resourcemanager.containerinstance.models.IpAddress;
import com.azure.resourcemanager.containerinstance.models.LogAnalytics;
import com.azure.resourcemanager.containerinstance.models.LogAnalyticsLogType;
import com.azure.resourcemanager.containerinstance.models.OperatingSystemTypes;
import com.azure.resourcemanager.containerinstance.models.Port;
import com.azure.resourcemanager.containerinstance.models.ResourceIdentityType;
import com.azure.resourcemanager.containerinstance.models.ResourceRequests;
import com.azure.resourcemanager.containerinstance.models.ResourceRequirements;
import com.azure.resourcemanager.containerinstance.models.Volume;
import com.azure.resourcemanager.containerinstance.models.VolumeMount;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ContainerGroups CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/ContainerGroupsCreateOrUpdate.json
*/
/**
* Sample code: ContainerGroupsCreateOrUpdate.
*
* @param manager Entry point to ContainerInstanceManager.
*/
public static void containerGroupsCreateOrUpdate(
com.azure.resourcemanager.containerinstance.ContainerInstanceManager manager) throws IOException {
manager.serviceClient().getContainerGroups().createOrUpdate("demo", "demo1", new ContainerGroupInner()
.withLocation("west us")
.withIdentity(new ContainerGroupIdentity().withType(ResourceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
new ContainerGroupIdentityUserAssignedIdentities())))
.withContainers(Arrays.asList(new Container().withName("demo1").withImage("nginx")
.withCommand(Arrays.asList()).withPorts(Arrays.asList(new ContainerPort().withPort(80)))
.withEnvironmentVariables(Arrays.asList())
.withResources(new ResourceRequirements().withRequests(new ResourceRequests().withMemoryInGB(1.5)
.withCpu(1.0).withGpu(new GpuResource().withCount(1).withSku(GpuSku.K80))))
.withVolumeMounts(Arrays.asList(
new VolumeMount().withName("volume1").withMountPath("/mnt/volume1").withReadOnly(false),
new VolumeMount().withName("volume2").withMountPath("/mnt/volume2").withReadOnly(false),
new VolumeMount().withName("volume3").withMountPath("/mnt/volume3").withReadOnly(true)))))
.withImageRegistryCredentials(Arrays.asList())
.withIpAddress(new IpAddress()
.withPorts(Arrays.asList(new Port().withProtocol(ContainerGroupNetworkProtocol.TCP).withPort(80)))
.withType(ContainerGroupIpAddressType.PUBLIC).withDnsNameLabel("dnsnamelabel1")
.withAutoGeneratedDomainNameLabelScope(DnsNameLabelReusePolicy.UNSECURE))
.withOsType(OperatingSystemTypes.LINUX)
.withVolumes(Arrays.asList(
new Volume().withName("volume1")
.withAzureFile(new AzureFileVolume().withShareName("shareName")
.withStorageAccountName("accountName").withStorageAccountKey("fakeTokenPlaceholder")),
new Volume().withName("volume2")
.withEmptyDir(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize("{}",
Object.class, SerializerEncoding.JSON)),
new Volume().withName("volume3")
.withSecret(mapOf("secretKey1", "fakeTokenPlaceholder", "secretKey2", "fakeTokenPlaceholder"))))
.withDiagnostics(new ContainerGroupDiagnostics().withLogAnalytics(new LogAnalytics()
.withWorkspaceId("workspaceid").withWorkspaceKey("fakeTokenPlaceholder")
.withLogType(LogAnalyticsLogType.CONTAINER_INSIGHTS)
.withMetadata(mapOf("test-key", "fakeTokenPlaceholder")).withWorkspaceResourceId(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace")))
.withSubnetIds(Arrays.asList(new ContainerGroupSubnetId().withId(
"[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]")))
.withDnsConfig(new DnsConfiguration().withNameServers(Arrays.asList("1.1.1.1"))
.withSearchDomains("cluster.local svc.cluster.local").withOptions("ndots:2")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerinstance
# USAGE
python container_groups_create_or_update.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerInstanceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.container_groups.begin_create_or_update(
resource_group_name="demo",
container_group_name="demo1",
container_group={
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {}
},
},
"location": "west us",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"environmentVariables": [],
"image": "nginx",
"ports": [{"port": 80}],
"resources": {"requests": {"cpu": 1, "gpu": {"count": 1, "sku": "K80"}, "memoryInGB": 1.5}},
"volumeMounts": [
{"mountPath": "/mnt/volume1", "name": "volume1", "readOnly": False},
{"mountPath": "/mnt/volume2", "name": "volume2", "readOnly": False},
{"mountPath": "/mnt/volume3", "name": "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": {
"autoGeneratedDomainNameLabelScope": "Unsecure",
"dnsNameLabel": "dnsnamelabel1",
"ports": [{"port": 80, "protocol": "TCP"}],
"type": "Public",
},
"osType": "Linux",
"subnetIds": [
{
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"
}
],
"volumes": [
{
"azureFile": {
"shareName": "shareName",
"storageAccountKey": "accountKey",
"storageAccountName": "accountName",
},
"name": "volume1",
},
{"emptyDir": {}, "name": "volume2"},
{
"name": "volume3",
"secret": {"secretKey1": "SecretValue1InBase64", "secretKey2": "SecretValue2InBase64"},
},
],
},
},
).result()
print(response)
# x-ms-original-file: 2026-07-01/ContainerGroupsCreateOrUpdate.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerinstance_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v3"
)
// Generated from example definition: 2026-07-01/ContainerGroupsCreateOrUpdate.json
func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupsCreateOrUpdate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerinstance.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{
Identity: &armcontainerinstance.ContainerGroupIdentity{
Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeSystemAssignedUserAssigned),
UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {},
},
},
Location: to.Ptr("west us"),
Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
Containers: []*armcontainerinstance.Container{
{
Name: to.Ptr("demo1"),
Properties: &armcontainerinstance.ContainerProperties{
Command: []*string{},
EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{},
Image: to.Ptr("nginx"),
Ports: []*armcontainerinstance.ContainerPort{
{
Port: to.Ptr[int32](80),
},
},
Resources: &armcontainerinstance.ResourceRequirements{
Requests: &armcontainerinstance.ResourceRequests{
CPU: to.Ptr[float64](1),
Gpu: &armcontainerinstance.GpuResource{
Count: to.Ptr[int32](1),
SKU: to.Ptr(armcontainerinstance.GpuSKUK80),
},
MemoryInGB: to.Ptr[float64](1.5),
},
},
VolumeMounts: []*armcontainerinstance.VolumeMount{
{
Name: to.Ptr("volume1"),
MountPath: to.Ptr("/mnt/volume1"),
ReadOnly: to.Ptr(false),
},
{
Name: to.Ptr("volume2"),
MountPath: to.Ptr("/mnt/volume2"),
ReadOnly: to.Ptr(false),
},
{
Name: to.Ptr("volume3"),
MountPath: to.Ptr("/mnt/volume3"),
ReadOnly: to.Ptr(true),
},
},
},
},
},
Diagnostics: &armcontainerinstance.ContainerGroupDiagnostics{
LogAnalytics: &armcontainerinstance.LogAnalytics{
LogType: to.Ptr(armcontainerinstance.LogAnalyticsLogTypeContainerInsights),
Metadata: map[string]*string{
"test-key": to.Ptr("test-metadata-value"),
},
WorkspaceID: to.Ptr("workspaceid"),
WorkspaceKey: to.Ptr("workspaceKey"),
WorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace"),
},
},
DNSConfig: &armcontainerinstance.DNSConfiguration{
NameServers: []*string{
to.Ptr("1.1.1.1"),
},
Options: to.Ptr("ndots:2"),
SearchDomains: to.Ptr("cluster.local svc.cluster.local"),
},
ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{},
IPAddress: &armcontainerinstance.IPAddress{
Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
AutoGeneratedDomainNameLabelScope: to.Ptr(armcontainerinstance.DNSNameLabelReusePolicyUnsecure),
DNSNameLabel: to.Ptr("dnsnamelabel1"),
Ports: []*armcontainerinstance.Port{
{
Port: to.Ptr[int32](80),
Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
},
},
},
OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
SubnetIDs: []*armcontainerinstance.ContainerGroupSubnetID{
{
ID: to.Ptr("[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"),
},
},
Volumes: []*armcontainerinstance.Volume{
{
Name: to.Ptr("volume1"),
AzureFile: &armcontainerinstance.AzureFileVolume{
ShareName: to.Ptr("shareName"),
StorageAccountKey: to.Ptr("accountKey"),
StorageAccountName: to.Ptr("accountName"),
},
},
{
Name: to.Ptr("volume2"),
EmptyDir: map[string]any{},
},
{
Name: to.Ptr("volume3"),
Secret: map[string]*string{
"secretKey1": to.Ptr("SecretValue1InBase64"),
"secretKey2": to.Ptr("SecretValue2InBase64"),
},
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to poll the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcontainerinstance.ContainerGroupsClientCreateOrUpdateResponse{
// ContainerGroup: armcontainerinstance.ContainerGroup{
// Name: to.Ptr("demo1"),
// Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"),
// Location: to.Ptr("WestUs"),
// Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
// Containers: []*armcontainerinstance.Container{
// {
// Name: to.Ptr("demo1"),
// Properties: &armcontainerinstance.ContainerProperties{
// Command: []*string{
// },
// EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{
// },
// Image: to.Ptr("nginx"),
// Ports: []*armcontainerinstance.ContainerPort{
// {
// Port: to.Ptr[int32](80),
// },
// },
// Resources: &armcontainerinstance.ResourceRequirements{
// Requests: &armcontainerinstance.ResourceRequests{
// CPU: to.Ptr[float64](1),
// Gpu: &armcontainerinstance.GpuResource{
// Count: to.Ptr[int32](1),
// SKU: to.Ptr(armcontainerinstance.GpuSKUK80),
// },
// MemoryInGB: to.Ptr[float64](1.5),
// },
// },
// VolumeMounts: []*armcontainerinstance.VolumeMount{
// {
// Name: to.Ptr("volume1"),
// MountPath: to.Ptr("/mnt/volume1"),
// ReadOnly: to.Ptr(false),
// },
// {
// Name: to.Ptr("volume2"),
// MountPath: to.Ptr("/mnt/volume2"),
// ReadOnly: to.Ptr(false),
// },
// {
// Name: to.Ptr("volume3"),
// MountPath: to.Ptr("/mnt/volume3"),
// ReadOnly: to.Ptr(true),
// },
// },
// },
// },
// },
// Diagnostics: &armcontainerinstance.ContainerGroupDiagnostics{
// LogAnalytics: &armcontainerinstance.LogAnalytics{
// WorkspaceID: to.Ptr("workspaceid"),
// },
// },
// DNSConfig: &armcontainerinstance.DNSConfiguration{
// NameServers: []*string{
// to.Ptr("1.1.1.1"),
// },
// Options: to.Ptr("ndots:2"),
// SearchDomains: to.Ptr("cluster.local svc.cluster.local"),
// },
// ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{
// },
// IPAddress: &armcontainerinstance.IPAddress{
// Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
// AutoGeneratedDomainNameLabelScope: to.Ptr(armcontainerinstance.DNSNameLabelReusePolicyUnsecure),
// DNSNameLabel: to.Ptr("dnsnamelabel1"),
// Fqdn: to.Ptr("dnsnamelabel1.azure-container.io"),
// IP: to.Ptr("10.0.0.1"),
// Ports: []*armcontainerinstance.Port{
// {
// Port: to.Ptr[int32](80),
// Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
// },
// },
// },
// IsCreatedFromStandbyPool: to.Ptr(false),
// OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// Volumes: []*armcontainerinstance.Volume{
// {
// Name: to.Ptr("volume1"),
// AzureFile: &armcontainerinstance.AzureFileVolume{
// ShareName: to.Ptr("shareName"),
// StorageAccountName: to.Ptr("accountName"),
// },
// },
// {
// Name: to.Ptr("volume2"),
// EmptyDir: map[string]any{
// },
// },
// {
// Name: to.Ptr("volume3"),
// Secret: map[string]*string{
// },
// },
// },
// },
// Zones: []*string{
// to.Ptr("1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
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-07-01/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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "WestUs",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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": {
"workspaceId": "workspaceid"
}
},
"dnsConfig": {
"nameServers": [
"1.1.1.1"
],
"options": "ndots:2",
"searchDomains": "cluster.local svc.cluster.local"
},
"imageRegistryCredentials": [],
"ipAddress": {
"type": "Public",
"autoGeneratedDomainNameLabelScope": "Unsecure",
"dnsNameLabel": "dnsnamelabel1",
"fqdn": "dnsnamelabel1.azure-container.io",
"ip": "10.0.0.1",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Succeeded",
"volumes": [
{
"name": "volume1",
"azureFile": {
"shareName": "shareName",
"storageAccountName": "accountName"
}
},
{
"name": "volume2",
"emptyDir": {}
},
{
"name": "volume3",
"secret": {}
}
]
},
"zones": [
"1"
]
}
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "WestUs",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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
}
]
}
}
],
"dnsConfig": {
"nameServers": [
"1.1.1.1"
]
},
"imageRegistryCredentials": [],
"ipAddress": {
"type": "Public",
"autoGeneratedDomainNameLabelScope": "Unsecure",
"dnsNameLabel": "dnsnamelabel1",
"fqdn": "dnsnamelabel1.azure-container.io",
"ip": "10.0.0.1",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Succeeded",
"volumes": [
{
"name": "volume1",
"azureFile": {
"shareName": "shareName",
"storageAccountName": "accountName"
}
},
{
"name": "volume2",
"emptyDir": {}
},
{
"name": "volume3",
"secret": {}
}
]
},
"zones": [
"1"
]
}
ContainerGroupsCreateOrUpdateManagedIdentityAzureFileshare
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1?api-version=2026-07-01
{
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {}
}
},
"location": "west us",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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",
"storageAccountName": "accountName",
"userManagedIdentityClientId": "00000000-0000-0000-0000-000000000000"
}
},
{
"name": "volume2",
"emptyDir": {}
},
{
"name": "volume3",
"secret": {
"secretKey1": "SecretValue1InBase64",
"secretKey2": "SecretValue2InBase64"
}
}
]
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.containerinstance.fluent.models.ContainerGroupInner;
import com.azure.resourcemanager.containerinstance.models.AzureFileVolume;
import com.azure.resourcemanager.containerinstance.models.Container;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupDiagnostics;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIdentity;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIdentityUserAssignedIdentities;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIpAddressType;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupNetworkProtocol;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupSubnetId;
import com.azure.resourcemanager.containerinstance.models.ContainerPort;
import com.azure.resourcemanager.containerinstance.models.DnsConfiguration;
import com.azure.resourcemanager.containerinstance.models.DnsNameLabelReusePolicy;
import com.azure.resourcemanager.containerinstance.models.GpuResource;
import com.azure.resourcemanager.containerinstance.models.GpuSku;
import com.azure.resourcemanager.containerinstance.models.IpAddress;
import com.azure.resourcemanager.containerinstance.models.LogAnalytics;
import com.azure.resourcemanager.containerinstance.models.LogAnalyticsLogType;
import com.azure.resourcemanager.containerinstance.models.OperatingSystemTypes;
import com.azure.resourcemanager.containerinstance.models.Port;
import com.azure.resourcemanager.containerinstance.models.ResourceIdentityType;
import com.azure.resourcemanager.containerinstance.models.ResourceRequests;
import com.azure.resourcemanager.containerinstance.models.ResourceRequirements;
import com.azure.resourcemanager.containerinstance.models.Volume;
import com.azure.resourcemanager.containerinstance.models.VolumeMount;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ContainerGroups CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/ContainerGroupsCreateOrUpdateManagedIdentityAzureFileshare.json
*/
/**
* Sample code: ContainerGroupsCreateOrUpdateManagedIdentityAzureFileshare.
*
* @param manager Entry point to ContainerInstanceManager.
*/
public static void containerGroupsCreateOrUpdateManagedIdentityAzureFileshare(
com.azure.resourcemanager.containerinstance.ContainerInstanceManager manager) throws IOException {
manager.serviceClient().getContainerGroups().createOrUpdate("demo", "demo1", new ContainerGroupInner()
.withLocation("west us")
.withIdentity(new ContainerGroupIdentity().withType(ResourceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
new ContainerGroupIdentityUserAssignedIdentities())))
.withContainers(Arrays.asList(new Container().withName("demo1").withImage("nginx")
.withCommand(Arrays.asList()).withPorts(Arrays.asList(new ContainerPort().withPort(80)))
.withEnvironmentVariables(Arrays.asList())
.withResources(new ResourceRequirements().withRequests(new ResourceRequests().withMemoryInGB(1.5)
.withCpu(1.0).withGpu(new GpuResource().withCount(1).withSku(GpuSku.K80))))
.withVolumeMounts(Arrays.asList(
new VolumeMount().withName("volume1").withMountPath("/mnt/volume1").withReadOnly(false),
new VolumeMount().withName("volume2").withMountPath("/mnt/volume2").withReadOnly(false),
new VolumeMount().withName("volume3").withMountPath("/mnt/volume3").withReadOnly(true)))))
.withImageRegistryCredentials(Arrays.asList())
.withIpAddress(new IpAddress()
.withPorts(Arrays.asList(new Port().withProtocol(ContainerGroupNetworkProtocol.TCP).withPort(80)))
.withType(ContainerGroupIpAddressType.PUBLIC).withDnsNameLabel("dnsnamelabel1")
.withAutoGeneratedDomainNameLabelScope(DnsNameLabelReusePolicy.UNSECURE))
.withOsType(OperatingSystemTypes.LINUX)
.withVolumes(Arrays.asList(new Volume().withName("volume1")
.withAzureFile(new AzureFileVolume().withShareName("shareName").withStorageAccountName("accountName")
.withUserAssignedIdentityClientId("00000000-0000-0000-0000-000000000000")),
new Volume().withName("volume2")
.withEmptyDir(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize("{}",
Object.class, SerializerEncoding.JSON)),
new Volume().withName("volume3")
.withSecret(mapOf("secretKey1", "fakeTokenPlaceholder", "secretKey2", "fakeTokenPlaceholder"))))
.withDiagnostics(new ContainerGroupDiagnostics().withLogAnalytics(new LogAnalytics()
.withWorkspaceId("workspaceid").withWorkspaceKey("fakeTokenPlaceholder")
.withLogType(LogAnalyticsLogType.CONTAINER_INSIGHTS)
.withMetadata(mapOf("test-key", "fakeTokenPlaceholder")).withWorkspaceResourceId(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace")))
.withSubnetIds(Arrays.asList(new ContainerGroupSubnetId().withId(
"[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]")))
.withDnsConfig(new DnsConfiguration().withNameServers(Arrays.asList("1.1.1.1"))
.withSearchDomains("cluster.local svc.cluster.local").withOptions("ndots:2")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerinstance
# USAGE
python container_groups_create_or_update_managed_identity_azure_fileshare.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerInstanceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.container_groups.begin_create_or_update(
resource_group_name="demo",
container_group_name="demo1",
container_group={
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {}
},
},
"location": "west us",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"environmentVariables": [],
"image": "nginx",
"ports": [{"port": 80}],
"resources": {"requests": {"cpu": 1, "gpu": {"count": 1, "sku": "K80"}, "memoryInGB": 1.5}},
"volumeMounts": [
{"mountPath": "/mnt/volume1", "name": "volume1", "readOnly": False},
{"mountPath": "/mnt/volume2", "name": "volume2", "readOnly": False},
{"mountPath": "/mnt/volume3", "name": "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": {
"autoGeneratedDomainNameLabelScope": "Unsecure",
"dnsNameLabel": "dnsnamelabel1",
"ports": [{"port": 80, "protocol": "TCP"}],
"type": "Public",
},
"osType": "Linux",
"subnetIds": [
{
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"
}
],
"volumes": [
{
"azureFile": {
"shareName": "shareName",
"storageAccountName": "accountName",
"userAssignedIdentityClientId": "00000000-0000-0000-0000-000000000000",
},
"name": "volume1",
},
{"emptyDir": {}, "name": "volume2"},
{
"name": "volume3",
"secret": {"secretKey1": "SecretValue1InBase64", "secretKey2": "SecretValue2InBase64"},
},
],
},
},
).result()
print(response)
# x-ms-original-file: 2026-07-01/ContainerGroupsCreateOrUpdateManagedIdentityAzureFileshare.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerinstance_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v3"
)
// Generated from example definition: 2026-07-01/ContainerGroupsCreateOrUpdateManagedIdentityAzureFileshare.json
func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupsCreateOrUpdateManagedIdentityAzureFileshare() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerinstance.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{
Identity: &armcontainerinstance.ContainerGroupIdentity{
Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeSystemAssignedUserAssigned),
UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {},
},
},
Location: to.Ptr("west us"),
Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
Containers: []*armcontainerinstance.Container{
{
Name: to.Ptr("demo1"),
Properties: &armcontainerinstance.ContainerProperties{
Command: []*string{},
EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{},
Image: to.Ptr("nginx"),
Ports: []*armcontainerinstance.ContainerPort{
{
Port: to.Ptr[int32](80),
},
},
Resources: &armcontainerinstance.ResourceRequirements{
Requests: &armcontainerinstance.ResourceRequests{
CPU: to.Ptr[float64](1),
Gpu: &armcontainerinstance.GpuResource{
Count: to.Ptr[int32](1),
SKU: to.Ptr(armcontainerinstance.GpuSKUK80),
},
MemoryInGB: to.Ptr[float64](1.5),
},
},
VolumeMounts: []*armcontainerinstance.VolumeMount{
{
Name: to.Ptr("volume1"),
MountPath: to.Ptr("/mnt/volume1"),
ReadOnly: to.Ptr(false),
},
{
Name: to.Ptr("volume2"),
MountPath: to.Ptr("/mnt/volume2"),
ReadOnly: to.Ptr(false),
},
{
Name: to.Ptr("volume3"),
MountPath: to.Ptr("/mnt/volume3"),
ReadOnly: to.Ptr(true),
},
},
},
},
},
Diagnostics: &armcontainerinstance.ContainerGroupDiagnostics{
LogAnalytics: &armcontainerinstance.LogAnalytics{
LogType: to.Ptr(armcontainerinstance.LogAnalyticsLogTypeContainerInsights),
Metadata: map[string]*string{
"test-key": to.Ptr("test-metadata-value"),
},
WorkspaceID: to.Ptr("workspaceid"),
WorkspaceKey: to.Ptr("workspaceKey"),
WorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace"),
},
},
DNSConfig: &armcontainerinstance.DNSConfiguration{
NameServers: []*string{
to.Ptr("1.1.1.1"),
},
Options: to.Ptr("ndots:2"),
SearchDomains: to.Ptr("cluster.local svc.cluster.local"),
},
ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{},
IPAddress: &armcontainerinstance.IPAddress{
Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
AutoGeneratedDomainNameLabelScope: to.Ptr(armcontainerinstance.DNSNameLabelReusePolicyUnsecure),
DNSNameLabel: to.Ptr("dnsnamelabel1"),
Ports: []*armcontainerinstance.Port{
{
Port: to.Ptr[int32](80),
Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
},
},
},
OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
SubnetIDs: []*armcontainerinstance.ContainerGroupSubnetID{
{
ID: to.Ptr("[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"),
},
},
Volumes: []*armcontainerinstance.Volume{
{
Name: to.Ptr("volume1"),
AzureFile: &armcontainerinstance.AzureFileVolume{
ShareName: to.Ptr("shareName"),
StorageAccountName: to.Ptr("accountName"),
UserAssignedIdentityClientID: to.Ptr("00000000-0000-0000-0000-000000000000"),
},
},
{
Name: to.Ptr("volume2"),
EmptyDir: map[string]any{},
},
{
Name: to.Ptr("volume3"),
Secret: map[string]*string{
"secretKey1": to.Ptr("SecretValue1InBase64"),
"secretKey2": to.Ptr("SecretValue2InBase64"),
},
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to poll the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcontainerinstance.ContainerGroupsClientCreateOrUpdateResponse{
// ContainerGroup: armcontainerinstance.ContainerGroup{
// Name: to.Ptr("demo1"),
// Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"),
// Location: to.Ptr("WestUs"),
// Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
// Containers: []*armcontainerinstance.Container{
// {
// Name: to.Ptr("demo1"),
// Properties: &armcontainerinstance.ContainerProperties{
// Command: []*string{
// },
// EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{
// },
// Image: to.Ptr("nginx"),
// Ports: []*armcontainerinstance.ContainerPort{
// {
// Port: to.Ptr[int32](80),
// },
// },
// Resources: &armcontainerinstance.ResourceRequirements{
// Requests: &armcontainerinstance.ResourceRequests{
// CPU: to.Ptr[float64](1),
// Gpu: &armcontainerinstance.GpuResource{
// Count: to.Ptr[int32](1),
// SKU: to.Ptr(armcontainerinstance.GpuSKUK80),
// },
// MemoryInGB: to.Ptr[float64](1.5),
// },
// },
// VolumeMounts: []*armcontainerinstance.VolumeMount{
// {
// Name: to.Ptr("volume1"),
// MountPath: to.Ptr("/mnt/volume1"),
// ReadOnly: to.Ptr(false),
// },
// {
// Name: to.Ptr("volume2"),
// MountPath: to.Ptr("/mnt/volume2"),
// ReadOnly: to.Ptr(false),
// },
// {
// Name: to.Ptr("volume3"),
// MountPath: to.Ptr("/mnt/volume3"),
// ReadOnly: to.Ptr(true),
// },
// },
// },
// },
// },
// Diagnostics: &armcontainerinstance.ContainerGroupDiagnostics{
// LogAnalytics: &armcontainerinstance.LogAnalytics{
// WorkspaceID: to.Ptr("workspaceid"),
// },
// },
// DNSConfig: &armcontainerinstance.DNSConfiguration{
// NameServers: []*string{
// to.Ptr("1.1.1.1"),
// },
// Options: to.Ptr("ndots:2"),
// SearchDomains: to.Ptr("cluster.local svc.cluster.local"),
// },
// ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{
// },
// IPAddress: &armcontainerinstance.IPAddress{
// Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
// AutoGeneratedDomainNameLabelScope: to.Ptr(armcontainerinstance.DNSNameLabelReusePolicyUnsecure),
// DNSNameLabel: to.Ptr("dnsnamelabel1"),
// Fqdn: to.Ptr("dnsnamelabel1.azure-container.io"),
// IP: to.Ptr("10.0.0.1"),
// Ports: []*armcontainerinstance.Port{
// {
// Port: to.Ptr[int32](80),
// Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
// },
// },
// },
// IsCreatedFromStandbyPool: to.Ptr(false),
// OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// Volumes: []*armcontainerinstance.Volume{
// {
// Name: to.Ptr("volume1"),
// AzureFile: &armcontainerinstance.AzureFileVolume{
// ShareName: to.Ptr("shareName"),
// StorageAccountName: to.Ptr("accountName"),
// UserAssignedIdentityClientID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// },
// {
// Name: to.Ptr("volume2"),
// EmptyDir: map[string]any{
// },
// },
// {
// Name: to.Ptr("volume3"),
// Secret: map[string]*string{
// },
// },
// },
// },
// Identity: &armcontainerinstance.ContainerGroupIdentity{
// UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{
// "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": &armcontainerinstance.UserAssignedIdentities{
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// },
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeUserAssigned),
// },
// Zones: []*string{
// to.Ptr("1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
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-07-01/ContainerGroupsCreateOrUpdateManagedIdentityAzureFileshare.json
*/
async function containerGroupsCreateOrUpdateManagedIdentityAzureFileshare() {
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",
storageAccountName: "accountName",
userAssignedIdentityClientId: "00000000-0000-0000-0000-000000000000",
},
},
{ name: "volume2", emptyDir: {} },
{
name: "volume3",
secret: { secretKey1: "SecretValue1InBase64", secretKey2: "SecretValue2InBase64" },
},
],
});
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "WestUs",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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": {
"workspaceId": "workspaceid"
}
},
"dnsConfig": {
"nameServers": [
"1.1.1.1"
],
"options": "ndots:2",
"searchDomains": "cluster.local svc.cluster.local"
},
"imageRegistryCredentials": [],
"ipAddress": {
"type": "Public",
"autoGeneratedDomainNameLabelScope": "Unsecure",
"dnsNameLabel": "dnsnamelabel1",
"fqdn": "dnsnamelabel1.azure-container.io",
"ip": "10.0.0.1",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Succeeded",
"volumes": [
{
"name": "volume1",
"azureFile": {
"shareName": "shareName",
"storageAccountName": "accountName",
"userManagedIdentityClientId": "00000000-0000-0000-0000-000000000000"
}
},
{
"name": "volume2",
"emptyDir": {}
},
{
"name": "volume3",
"secret": {}
}
]
},
"identity": {
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {
"principalId": "00000000-0000-0000-0000-000000000000",
"clientId": "00000000-0000-0000-0000-000000000000"
}
},
"tenantId": "00000000-0000-0000-0000-000000000000",
"type": "UserAssigned"
},
"zones": [
"1"
]
}
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "WestUs",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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
}
]
}
}
],
"dnsConfig": {
"nameServers": [
"1.1.1.1"
]
},
"imageRegistryCredentials": [],
"ipAddress": {
"type": "Public",
"autoGeneratedDomainNameLabelScope": "Unsecure",
"dnsNameLabel": "dnsnamelabel1",
"fqdn": "dnsnamelabel1.azure-container.io",
"ip": "10.0.0.1",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Succeeded",
"volumes": [
{
"name": "volume1",
"azureFile": {
"shareName": "shareName",
"storageAccountName": "accountName",
"userManagedIdentityClientId": "00000000-0000-0000-0000-000000000000"
}
},
{
"name": "volume2",
"emptyDir": {}
},
{
"name": "volume3",
"secret": {}
}
]
},
"identity": {
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {
"principalId": "00000000-0000-0000-0000-000000000000",
"clientId": "00000000-0000-0000-0000-000000000000"
}
},
"tenantId": "00000000-0000-0000-0000-000000000000",
"type": "UserAssigned"
},
"zones": [
"1"
]
}
ContainerGroupsCreateOrUpdateSecretReference
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1?api-version=2026-07-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {}
}
},
"location": "west us",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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"
}
}
]
}
}
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.containerinstance.fluent.models.ContainerGroupInner;
import com.azure.resourcemanager.containerinstance.models.AzureFileVolume;
import com.azure.resourcemanager.containerinstance.models.Container;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupDiagnostics;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIdentity;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIdentityUserAssignedIdentities;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIpAddressType;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupNetworkProtocol;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupSubnetId;
import com.azure.resourcemanager.containerinstance.models.ContainerPort;
import com.azure.resourcemanager.containerinstance.models.DnsConfiguration;
import com.azure.resourcemanager.containerinstance.models.DnsNameLabelReusePolicy;
import com.azure.resourcemanager.containerinstance.models.EnvironmentVariable;
import com.azure.resourcemanager.containerinstance.models.GpuResource;
import com.azure.resourcemanager.containerinstance.models.GpuSku;
import com.azure.resourcemanager.containerinstance.models.ImageRegistryCredential;
import com.azure.resourcemanager.containerinstance.models.IpAddress;
import com.azure.resourcemanager.containerinstance.models.LogAnalytics;
import com.azure.resourcemanager.containerinstance.models.LogAnalyticsLogType;
import com.azure.resourcemanager.containerinstance.models.OperatingSystemTypes;
import com.azure.resourcemanager.containerinstance.models.Port;
import com.azure.resourcemanager.containerinstance.models.ResourceIdentityType;
import com.azure.resourcemanager.containerinstance.models.ResourceRequests;
import com.azure.resourcemanager.containerinstance.models.ResourceRequirements;
import com.azure.resourcemanager.containerinstance.models.SecretReference;
import com.azure.resourcemanager.containerinstance.models.Volume;
import com.azure.resourcemanager.containerinstance.models.VolumeMount;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ContainerGroups CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/ContainerGroupsCreateOrUpdateSecretReference.json
*/
/**
* Sample code: ContainerGroupsCreateOrUpdateSecretReference.
*
* @param manager Entry point to ContainerInstanceManager.
*/
public static void containerGroupsCreateOrUpdateSecretReference(
com.azure.resourcemanager.containerinstance.ContainerInstanceManager manager) throws IOException {
manager.serviceClient().getContainerGroups().createOrUpdate("demo", "demo1", new ContainerGroupInner()
.withLocation("west us")
.withIdentity(new ContainerGroupIdentity().withType(ResourceIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
new ContainerGroupIdentityUserAssignedIdentities())))
.withSecretReferences(Arrays.asList(new SecretReference().withName("envSecretRef").withIdentity(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name")
.withSecretReferenceUri("fakeTokenPlaceholder"),
new SecretReference().withName("accountKeyRef").withIdentity(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name")
.withSecretReferenceUri("fakeTokenPlaceholder"),
new SecretReference().withName("volumeSecretRef").withIdentity(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name")
.withSecretReferenceUri("fakeTokenPlaceholder"),
new SecretReference().withName("privateRegistryKeyRef").withIdentity(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name")
.withSecretReferenceUri("fakeTokenPlaceholder")))
.withContainers(Arrays.asList(new Container().withName("demo1").withImage("privateRegistryImage")
.withCommand(Arrays.asList()).withPorts(Arrays.asList(new ContainerPort().withPort(80)))
.withEnvironmentVariables(Arrays
.asList(new EnvironmentVariable().withName("envSecret").withSecureValueReference("envSecretRef")))
.withResources(new ResourceRequirements().withRequests(new ResourceRequests().withMemoryInGB(1.5)
.withCpu(1.0).withGpu(new GpuResource().withCount(1).withSku(GpuSku.K80))))
.withVolumeMounts(Arrays.asList(
new VolumeMount().withName("volume1").withMountPath("/mnt/volume1").withReadOnly(false),
new VolumeMount().withName("volume2").withMountPath("/mnt/volume2").withReadOnly(false),
new VolumeMount().withName("volume3").withMountPath("/mnt/volume3").withReadOnly(true)))))
.withImageRegistryCredentials(
Arrays.asList(new ImageRegistryCredential().withServer("demoregistry.azurecr.io")
.withUsername("registryUserName").withPasswordReference("fakeTokenPlaceholder")))
.withIpAddress(new IpAddress()
.withPorts(Arrays.asList(new Port().withProtocol(ContainerGroupNetworkProtocol.TCP).withPort(80)))
.withType(ContainerGroupIpAddressType.PUBLIC).withDnsNameLabel("dnsnamelabel1")
.withAutoGeneratedDomainNameLabelScope(DnsNameLabelReusePolicy.UNSECURE))
.withOsType(OperatingSystemTypes.LINUX)
.withVolumes(Arrays.asList(
new Volume().withName("volume1")
.withAzureFile(new AzureFileVolume().withShareName("shareName")
.withStorageAccountName("accountName").withStorageAccountKeyReference("fakeTokenPlaceholder")),
new Volume().withName("volume2")
.withEmptyDir(SerializerFactory.createDefaultManagementSerializerAdapter().deserialize("{}",
Object.class, SerializerEncoding.JSON)),
new Volume().withName("volume3").withSecret(mapOf("secretKey1", "fakeTokenPlaceholder"))
.withSecretReference(mapOf("secretKey2", "fakeTokenPlaceholder"))))
.withDiagnostics(new ContainerGroupDiagnostics().withLogAnalytics(new LogAnalytics()
.withWorkspaceId("workspaceid").withWorkspaceKey("fakeTokenPlaceholder")
.withLogType(LogAnalyticsLogType.CONTAINER_INSIGHTS)
.withMetadata(mapOf("test-key", "fakeTokenPlaceholder")).withWorkspaceResourceId(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace")))
.withSubnetIds(Arrays.asList(new ContainerGroupSubnetId().withId(
"[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]")))
.withDnsConfig(new DnsConfiguration().withNameServers(Arrays.asList("1.1.1.1"))
.withSearchDomains("cluster.local svc.cluster.local").withOptions("ndots:2")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerinstance
# USAGE
python container_groups_create_or_update_secret_reference.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerInstanceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.container_groups.begin_create_or_update(
resource_group_name="demo",
container_group_name="demo1",
container_group={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {}
},
},
"location": "west us",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"command": [],
"environmentVariables": [{"name": "envSecret", "secureValueReference": "envSecretRef"}],
"image": "privateRegistryImage",
"ports": [{"port": 80}],
"resources": {"requests": {"cpu": 1, "gpu": {"count": 1, "sku": "K80"}, "memoryInGB": 1.5}},
"volumeMounts": [
{"mountPath": "/mnt/volume1", "name": "volume1", "readOnly": False},
{"mountPath": "/mnt/volume2", "name": "volume2", "readOnly": False},
{"mountPath": "/mnt/volume3", "name": "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": {
"autoGeneratedDomainNameLabelScope": "Unsecure",
"dnsNameLabel": "dnsnamelabel1",
"ports": [{"port": 80, "protocol": "TCP"}],
"type": "Public",
},
"osType": "Linux",
"secretReferences": [
{
"identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
"name": "envSecretRef",
"secretReferenceUri": "https://keyvaultname.vault.azure.net/secrets/envSecret",
},
{
"identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
"name": "accountKeyRef",
"secretReferenceUri": "https://keyvaultname.vault.azure.net/secrets/accountKey",
},
{
"identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
"name": "volumeSecretRef",
"secretReferenceUri": "https://keyvaultname.vault.azure.net/secrets/volumeSecret",
},
{
"identity": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name",
"name": "privateRegistryKeyRef",
"secretReferenceUri": "https://keyvaultname.vault.azure.net/secrets/privateRegistryKey",
},
],
"subnetIds": [
{
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"
}
],
"volumes": [
{
"azureFile": {
"shareName": "shareName",
"storageAccountKeyReference": "accountKeyRef",
"storageAccountName": "accountName",
},
"name": "volume1",
},
{"emptyDir": {}, "name": "volume2"},
{
"name": "volume3",
"secret": {"secretKey1": "SecretValue1InBase64"},
"secretReference": {"secretKey2": "volumeSecretRef"},
},
],
},
},
).result()
print(response)
# x-ms-original-file: 2026-07-01/ContainerGroupsCreateOrUpdateSecretReference.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerinstance_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v3"
)
// Generated from example definition: 2026-07-01/ContainerGroupsCreateOrUpdateSecretReference.json
func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupsCreateOrUpdateSecretReference() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerinstance.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{
Identity: &armcontainerinstance.ContainerGroupIdentity{
Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {},
},
},
Location: to.Ptr("west us"),
Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
Containers: []*armcontainerinstance.Container{
{
Name: to.Ptr("demo1"),
Properties: &armcontainerinstance.ContainerProperties{
Command: []*string{},
EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{
{
Name: to.Ptr("envSecret"),
SecureValueReference: to.Ptr("envSecretRef"),
},
},
Image: to.Ptr("privateRegistryImage"),
Ports: []*armcontainerinstance.ContainerPort{
{
Port: to.Ptr[int32](80),
},
},
Resources: &armcontainerinstance.ResourceRequirements{
Requests: &armcontainerinstance.ResourceRequests{
CPU: to.Ptr[float64](1),
Gpu: &armcontainerinstance.GpuResource{
Count: to.Ptr[int32](1),
SKU: to.Ptr(armcontainerinstance.GpuSKUK80),
},
MemoryInGB: to.Ptr[float64](1.5),
},
},
VolumeMounts: []*armcontainerinstance.VolumeMount{
{
Name: to.Ptr("volume1"),
MountPath: to.Ptr("/mnt/volume1"),
ReadOnly: to.Ptr(false),
},
{
Name: to.Ptr("volume2"),
MountPath: to.Ptr("/mnt/volume2"),
ReadOnly: to.Ptr(false),
},
{
Name: to.Ptr("volume3"),
MountPath: to.Ptr("/mnt/volume3"),
ReadOnly: to.Ptr(true),
},
},
},
},
},
Diagnostics: &armcontainerinstance.ContainerGroupDiagnostics{
LogAnalytics: &armcontainerinstance.LogAnalytics{
LogType: to.Ptr(armcontainerinstance.LogAnalyticsLogTypeContainerInsights),
Metadata: map[string]*string{
"test-key": to.Ptr("test-metadata-value"),
},
WorkspaceID: to.Ptr("workspaceid"),
WorkspaceKey: to.Ptr("workspaceKey"),
WorkspaceResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace"),
},
},
DNSConfig: &armcontainerinstance.DNSConfiguration{
NameServers: []*string{
to.Ptr("1.1.1.1"),
},
Options: to.Ptr("ndots:2"),
SearchDomains: to.Ptr("cluster.local svc.cluster.local"),
},
ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{
{
PasswordReference: to.Ptr("privateRegistryKeyRef"),
Server: to.Ptr("demoregistry.azurecr.io"),
Username: to.Ptr("registryUserName"),
},
},
IPAddress: &armcontainerinstance.IPAddress{
Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
AutoGeneratedDomainNameLabelScope: to.Ptr(armcontainerinstance.DNSNameLabelReusePolicyUnsecure),
DNSNameLabel: to.Ptr("dnsnamelabel1"),
Ports: []*armcontainerinstance.Port{
{
Port: to.Ptr[int32](80),
Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
},
},
},
OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
SecretReferences: []*armcontainerinstance.SecretReference{
{
Name: to.Ptr("envSecretRef"),
Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name"),
SecretReferenceURI: to.Ptr("https://keyvaultname.vault.azure.net/secrets/envSecret"),
},
{
Name: to.Ptr("accountKeyRef"),
Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name"),
SecretReferenceURI: to.Ptr("https://keyvaultname.vault.azure.net/secrets/accountKey"),
},
{
Name: to.Ptr("volumeSecretRef"),
Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name"),
SecretReferenceURI: to.Ptr("https://keyvaultname.vault.azure.net/secrets/volumeSecret"),
},
{
Name: to.Ptr("privateRegistryKeyRef"),
Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name"),
SecretReferenceURI: to.Ptr("https://keyvaultname.vault.azure.net/secrets/privateRegistryKey"),
},
},
SubnetIDs: []*armcontainerinstance.ContainerGroupSubnetID{
{
ID: to.Ptr("[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]"),
},
},
Volumes: []*armcontainerinstance.Volume{
{
Name: to.Ptr("volume1"),
AzureFile: &armcontainerinstance.AzureFileVolume{
ShareName: to.Ptr("shareName"),
StorageAccountKeyReference: to.Ptr("accountKeyRef"),
StorageAccountName: to.Ptr("accountName"),
},
},
{
Name: to.Ptr("volume2"),
EmptyDir: map[string]any{},
},
{
Name: to.Ptr("volume3"),
Secret: map[string]*string{
"secretKey1": to.Ptr("SecretValue1InBase64"),
},
SecretReference: map[string]*string{
"secretKey2": to.Ptr("volumeSecretRef"),
},
},
},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to poll the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcontainerinstance.ContainerGroupsClientCreateOrUpdateResponse{
// ContainerGroup: armcontainerinstance.ContainerGroup{
// Name: to.Ptr("demo1"),
// Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"),
// ID: to.Ptr("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"),
// Identity: &armcontainerinstance.ContainerGroupIdentity{
// Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeUserAssigned),
// TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{
// "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": &armcontainerinstance.UserAssignedIdentities{
// ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// },
// },
// },
// Location: to.Ptr("WestUs"),
// Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
// Containers: []*armcontainerinstance.Container{
// {
// Name: to.Ptr("demo1"),
// Properties: &armcontainerinstance.ContainerProperties{
// Command: []*string{
// },
// EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{
// {
// Name: to.Ptr("envSecret"),
// SecureValueReference: to.Ptr("envSecretRef"),
// },
// },
// Image: to.Ptr("privateRegistryImage"),
// Ports: []*armcontainerinstance.ContainerPort{
// {
// Port: to.Ptr[int32](80),
// },
// },
// Resources: &armcontainerinstance.ResourceRequirements{
// Requests: &armcontainerinstance.ResourceRequests{
// CPU: to.Ptr[float64](1),
// Gpu: &armcontainerinstance.GpuResource{
// Count: to.Ptr[int32](1),
// SKU: to.Ptr(armcontainerinstance.GpuSKUK80),
// },
// MemoryInGB: to.Ptr[float64](1.5),
// },
// },
// VolumeMounts: []*armcontainerinstance.VolumeMount{
// {
// Name: to.Ptr("volume1"),
// MountPath: to.Ptr("/mnt/volume1"),
// ReadOnly: to.Ptr(false),
// },
// {
// Name: to.Ptr("volume2"),
// MountPath: to.Ptr("/mnt/volume2"),
// ReadOnly: to.Ptr(false),
// },
// {
// Name: to.Ptr("volume3"),
// MountPath: to.Ptr("/mnt/volume3"),
// ReadOnly: to.Ptr(true),
// },
// },
// },
// },
// },
// Diagnostics: &armcontainerinstance.ContainerGroupDiagnostics{
// LogAnalytics: &armcontainerinstance.LogAnalytics{
// WorkspaceID: to.Ptr("workspaceid"),
// },
// },
// DNSConfig: &armcontainerinstance.DNSConfiguration{
// NameServers: []*string{
// to.Ptr("1.1.1.1"),
// },
// Options: to.Ptr("ndots:2"),
// SearchDomains: to.Ptr("cluster.local svc.cluster.local"),
// },
// ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{
// {
// PasswordReference: to.Ptr("privateRegistryKeyRef"),
// Server: to.Ptr("demoregistry.azurecr.io"),
// Username: to.Ptr("registryUserName"),
// },
// },
// IPAddress: &armcontainerinstance.IPAddress{
// Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
// AutoGeneratedDomainNameLabelScope: to.Ptr(armcontainerinstance.DNSNameLabelReusePolicyUnsecure),
// DNSNameLabel: to.Ptr("dnsnamelabel1"),
// Fqdn: to.Ptr("dnsnamelabel1.azure-container.io"),
// IP: to.Ptr("10.0.0.1"),
// Ports: []*armcontainerinstance.Port{
// {
// Port: to.Ptr[int32](80),
// Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
// },
// },
// },
// IsCreatedFromStandbyPool: to.Ptr(false),
// OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
// ProvisioningState: to.Ptr("Succeeded"),
// SecretReferences: []*armcontainerinstance.SecretReference{
// {
// Name: to.Ptr("envSecretRef"),
// Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name"),
// SecretReferenceURI: to.Ptr("https://keyvaultname.vault.azure.net/secrets/envSecret"),
// },
// {
// Name: to.Ptr("accountKeyRef"),
// Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name"),
// SecretReferenceURI: to.Ptr("https://keyvaultname.vault.azure.net/secrets/accountKey"),
// },
// {
// Name: to.Ptr("volumeSecretRef"),
// Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name"),
// SecretReferenceURI: to.Ptr("https://keyvaultname.vault.azure.net/secrets/volumeSecret"),
// },
// {
// Name: to.Ptr("privateRegistryKeyRef"),
// Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name"),
// SecretReferenceURI: to.Ptr("https://keyvaultname.vault.azure.net/secrets/privateRegistryKey"),
// },
// },
// Volumes: []*armcontainerinstance.Volume{
// {
// Name: to.Ptr("volume1"),
// AzureFile: &armcontainerinstance.AzureFileVolume{
// ShareName: to.Ptr("shareName"),
// StorageAccountKeyReference: to.Ptr("accountKeyRef"),
// StorageAccountName: to.Ptr("accountName"),
// },
// },
// {
// Name: to.Ptr("volume2"),
// EmptyDir: map[string]any{
// },
// },
// {
// Name: to.Ptr("volume3"),
// Secret: map[string]*string{
// },
// SecretReference: map[string]*string{
// "secretKey2": to.Ptr("volumeSecretRef"),
// },
// },
// },
// },
// Zones: []*string{
// to.Ptr("1"),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
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-07-01/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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"identity": {
"type": "UserAssigned",
"tenantId": "00000000-0000-0000-0000-000000000000",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {
"clientId": "00000000-0000-0000-0000-000000000000",
"principalId": "00000000-0000-0000-0000-000000000000"
}
}
},
"location": "WestUs",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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": {
"workspaceId": "workspaceid"
}
},
"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",
"fqdn": "dnsnamelabel1.azure-container.io",
"ip": "10.0.0.1",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Succeeded",
"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"
}
],
"volumes": [
{
"name": "volume1",
"azureFile": {
"shareName": "shareName",
"storageAccountKeyReference": "accountKeyRef",
"storageAccountName": "accountName"
}
},
{
"name": "volume2",
"emptyDir": {}
},
{
"name": "volume3",
"secret": {},
"secretReference": {
"secretKey2": "volumeSecretRef"
}
}
]
},
"zones": [
"1"
]
}
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"identity": {
"type": "UserAssigned",
"tenantId": "00000000-0000-0000-0000-000000000000",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name": {
"clientId": "00000000-0000-0000-0000-000000000000",
"principalId": "00000000-0000-0000-0000-000000000000"
}
}
},
"location": "WestUs",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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
}
]
}
}
],
"dnsConfig": {
"nameServers": [
"1.1.1.1"
]
},
"imageRegistryCredentials": [
{
"passwordReference": "privateRegistryKeyRef",
"server": "demoregistry.azurecr.io",
"username": "registryUserName"
}
],
"ipAddress": {
"type": "Public",
"autoGeneratedDomainNameLabelScope": "Unsecure",
"dnsNameLabel": "dnsnamelabel1",
"fqdn": "dnsnamelabel1.azure-container.io",
"ip": "10.0.0.1",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Succeeded",
"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"
}
],
"volumes": [
{
"name": "volume1",
"azureFile": {
"shareName": "shareName",
"storageAccountKeyReference": "accountKeyRef",
"storageAccountName": "accountName"
}
},
{
"name": "volume2",
"emptyDir": {}
},
{
"name": "volume3",
"secret": {},
"secretReference": {
"secretKey2": "volumeSecretRef"
}
}
]
},
"zones": [
"1"
]
}
ContainerGroupsCreateWithPriority
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1?api-version=2026-07-01
{
"location": "eastus",
"properties": {
"containers": [
{
"name": "test-container-001",
"properties": {
"command": [
"/bin/sh",
"-c",
"sleep 10"
],
"image": "alpine:latest",
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1
}
}
}
}
],
"osType": "Linux",
"priority": "Spot",
"restartPolicy": "Never",
"sku": "Standard"
}
}
import com.azure.resourcemanager.containerinstance.fluent.models.ContainerGroupInner;
import com.azure.resourcemanager.containerinstance.models.Container;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupPriority;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupRestartPolicy;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupSku;
import com.azure.resourcemanager.containerinstance.models.OperatingSystemTypes;
import com.azure.resourcemanager.containerinstance.models.ResourceRequests;
import com.azure.resourcemanager.containerinstance.models.ResourceRequirements;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ContainerGroups CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/ContainerGroupsCreatePriority.json
*/
/**
* Sample code: ContainerGroupsCreateWithPriority.
*
* @param manager Entry point to ContainerInstanceManager.
*/
public static void containerGroupsCreateWithPriority(
com.azure.resourcemanager.containerinstance.ContainerInstanceManager manager) {
manager.serviceClient().getContainerGroups().createOrUpdate("demo", "demo1", new ContainerGroupInner()
.withLocation("eastus")
.withContainers(Arrays.asList(new Container().withName("test-container-001").withImage("alpine:latest")
.withCommand(Arrays.asList("/bin/sh", "-c", "sleep 10")).withResources(
new ResourceRequirements().withRequests(new ResourceRequests().withMemoryInGB(1.0).withCpu(1.0)))))
.withRestartPolicy(ContainerGroupRestartPolicy.NEVER).withOsType(OperatingSystemTypes.LINUX)
.withSku(ContainerGroupSku.STANDARD).withPriority(ContainerGroupPriority.SPOT),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerinstance
# USAGE
python container_groups_create_priority.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerInstanceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.container_groups.begin_create_or_update(
resource_group_name="demo",
container_group_name="demo1",
container_group={
"location": "eastus",
"properties": {
"containers": [
{
"name": "test-container-001",
"properties": {
"command": ["/bin/sh", "-c", "sleep 10"],
"image": "alpine:latest",
"resources": {"requests": {"cpu": 1, "memoryInGB": 1}},
},
}
],
"osType": "Linux",
"priority": "Spot",
"restartPolicy": "Never",
"sku": "Standard",
},
},
).result()
print(response)
# x-ms-original-file: 2026-07-01/ContainerGroupsCreatePriority.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerinstance_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v3"
)
// Generated from example definition: 2026-07-01/ContainerGroupsCreatePriority.json
func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupsCreateWithPriority() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerinstance.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{
Location: to.Ptr("eastus"),
Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
Containers: []*armcontainerinstance.Container{
{
Name: to.Ptr("test-container-001"),
Properties: &armcontainerinstance.ContainerProperties{
Command: []*string{
to.Ptr("/bin/sh"),
to.Ptr("-c"),
to.Ptr("sleep 10"),
},
Image: to.Ptr("alpine:latest"),
Resources: &armcontainerinstance.ResourceRequirements{
Requests: &armcontainerinstance.ResourceRequests{
CPU: to.Ptr[float64](1),
MemoryInGB: to.Ptr[float64](1),
},
},
},
},
},
OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
Priority: to.Ptr(armcontainerinstance.ContainerGroupPrioritySpot),
RestartPolicy: to.Ptr(armcontainerinstance.ContainerGroupRestartPolicyNever),
SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to poll the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcontainerinstance.ContainerGroupsClientCreateOrUpdateResponse{
// ContainerGroup: armcontainerinstance.ContainerGroup{
// Name: to.Ptr("demo1"),
// Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"),
// ID: to.Ptr("/subscriptions/subId/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1"),
// Location: to.Ptr("eastus"),
// Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
// Containers: []*armcontainerinstance.Container{
// {
// Name: to.Ptr("test-container-001"),
// Properties: &armcontainerinstance.ContainerProperties{
// Command: []*string{
// to.Ptr("/bin/sh"),
// to.Ptr("-c"),
// to.Ptr("sleep 10"),
// },
// EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{
// },
// Image: to.Ptr("alpine:latest"),
// Ports: []*armcontainerinstance.ContainerPort{
// },
// Resources: &armcontainerinstance.ResourceRequirements{
// Requests: &armcontainerinstance.ResourceRequests{
// CPU: to.Ptr[float64](1),
// MemoryInGB: to.Ptr[float64](1),
// },
// },
// },
// },
// },
// InitContainers: []*armcontainerinstance.InitContainerDefinition{
// },
// InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{
// Events: []*armcontainerinstance.Event{
// },
// State: to.Ptr("Succeeded"),
// },
// IsCreatedFromStandbyPool: to.Ptr(false),
// OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
// Priority: to.Ptr(armcontainerinstance.ContainerGroupPrioritySpot),
// ProvisioningState: to.Ptr("Succeeded"),
// RestartPolicy: to.Ptr(armcontainerinstance.ContainerGroupRestartPolicyNever),
// SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
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-07-01/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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subId/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "eastus",
"properties": {
"containers": [
{
"name": "test-container-001",
"properties": {
"command": [
"/bin/sh",
"-c",
"sleep 10"
],
"environmentVariables": [],
"image": "alpine:latest",
"ports": [],
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1
}
}
}
}
],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Succeeded"
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"priority": "Spot",
"provisioningState": "Succeeded",
"restartPolicy": "Never",
"sku": "Standard"
}
}
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/subId/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"location": "eastus",
"properties": {
"containers": [
{
"name": "test-container-001",
"properties": {
"command": [
"/bin/sh",
"-c",
"sleep 10"
],
"environmentVariables": [],
"image": "alpine:latest",
"ports": [],
"resources": {
"requests": {
"cpu": 1,
"memoryInGB": 1
}
}
}
}
],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Created"
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"priority": "Spot",
"provisioningState": "Created",
"restartPolicy": "Never",
"sku": "Standard"
}
}
ContainerGroupWithEncryptionProperties
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/demo1?api-version=2026-07-01
{
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity": {}
}
},
"location": "eastus2",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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"
}
}
import com.azure.resourcemanager.containerinstance.fluent.models.ContainerGroupInner;
import com.azure.resourcemanager.containerinstance.models.Container;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIdentity;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIdentityUserAssignedIdentities;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupIpAddressType;
import com.azure.resourcemanager.containerinstance.models.ContainerGroupNetworkProtocol;
import com.azure.resourcemanager.containerinstance.models.ContainerPort;
import com.azure.resourcemanager.containerinstance.models.EncryptionProperties;
import com.azure.resourcemanager.containerinstance.models.IpAddress;
import com.azure.resourcemanager.containerinstance.models.OperatingSystemTypes;
import com.azure.resourcemanager.containerinstance.models.Port;
import com.azure.resourcemanager.containerinstance.models.ResourceIdentityType;
import com.azure.resourcemanager.containerinstance.models.ResourceRequests;
import com.azure.resourcemanager.containerinstance.models.ResourceRequirements;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ContainerGroups CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: 2026-07-01/ContainerGroupEncryptionProperties.json
*/
/**
* Sample code: ContainerGroupWithEncryptionProperties.
*
* @param manager Entry point to ContainerInstanceManager.
*/
public static void containerGroupWithEncryptionProperties(
com.azure.resourcemanager.containerinstance.ContainerInstanceManager manager) {
manager.serviceClient().getContainerGroups().createOrUpdate("demo", "demo1", new ContainerGroupInner()
.withLocation("eastus2")
.withIdentity(new ContainerGroupIdentity().withType(ResourceIdentityType.USER_ASSIGNED)
.withUserAssignedIdentities(mapOf(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity",
new ContainerGroupIdentityUserAssignedIdentities())))
.withContainers(Arrays.asList(new Container().withName("demo1").withImage("nginx")
.withCommand(Arrays.asList()).withPorts(Arrays.asList(new ContainerPort().withPort(80)))
.withEnvironmentVariables(Arrays.asList()).withResources(
new ResourceRequirements().withRequests(new ResourceRequests().withMemoryInGB(1.5).withCpu(1.0)))))
.withImageRegistryCredentials(Arrays.asList())
.withIpAddress(new IpAddress()
.withPorts(Arrays.asList(new Port().withProtocol(ContainerGroupNetworkProtocol.TCP).withPort(80)))
.withType(ContainerGroupIpAddressType.PUBLIC))
.withOsType(OperatingSystemTypes.LINUX)
.withEncryptionProperties(new EncryptionProperties()
.withVaultBaseUrl("https://testkeyvault.vault.azure.net").withKeyName("fakeTokenPlaceholder")
.withKeyVersion("fakeTokenPlaceholder").withIdentity(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity")),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-containerinstance
# USAGE
python container_group_encryption_properties.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ContainerInstanceManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.container_groups.begin_create_or_update(
resource_group_name="demo",
container_group_name="demo1",
container_group={
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity": {}
},
},
"location": "eastus2",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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": {"ports": [{"port": 80, "protocol": "TCP"}], "type": "Public"},
"osType": "Linux",
},
},
).result()
print(response)
# x-ms-original-file: 2026-07-01/ContainerGroupEncryptionProperties.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcontainerinstance_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerinstance/armcontainerinstance/v3"
)
// Generated from example definition: 2026-07-01/ContainerGroupEncryptionProperties.json
func ExampleContainerGroupsClient_BeginCreateOrUpdate_containerGroupWithEncryptionProperties() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcontainerinstance.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
poller, err := clientFactory.NewContainerGroupsClient().BeginCreateOrUpdate(ctx, "demo", "demo1", armcontainerinstance.ContainerGroup{
Identity: &armcontainerinstance.ContainerGroupIdentity{
Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity": {},
},
},
Location: to.Ptr("eastus2"),
Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
Containers: []*armcontainerinstance.Container{
{
Name: to.Ptr("demo1"),
Properties: &armcontainerinstance.ContainerProperties{
Command: []*string{},
EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{},
Image: to.Ptr("nginx"),
Ports: []*armcontainerinstance.ContainerPort{
{
Port: to.Ptr[int32](80),
},
},
Resources: &armcontainerinstance.ResourceRequirements{
Requests: &armcontainerinstance.ResourceRequests{
CPU: to.Ptr[float64](1),
MemoryInGB: to.Ptr[float64](1.5),
},
},
},
},
},
EncryptionProperties: &armcontainerinstance.EncryptionProperties{
Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity"),
KeyName: to.Ptr("test-key"),
KeyVersion: to.Ptr("<key version>"),
VaultBaseURL: to.Ptr("https://testkeyvault.vault.azure.net"),
},
ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{},
IPAddress: &armcontainerinstance.IPAddress{
Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
Ports: []*armcontainerinstance.Port{
{
Port: to.Ptr[int32](80),
Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
},
},
},
OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
res, err := poller.PollUntilDone(ctx, nil)
if err != nil {
log.Fatalf("failed to poll the result: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcontainerinstance.ContainerGroupsClientCreateOrUpdateResponse{
// ContainerGroup: armcontainerinstance.ContainerGroup{
// Name: to.Ptr("demo1"),
// Type: to.Ptr("Microsoft.ContainerInstance/containerGroups"),
// ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1"),
// Identity: &armcontainerinstance.ContainerGroupIdentity{
// Type: to.Ptr(armcontainerinstance.ResourceIdentityTypeUserAssigned),
// TenantID: to.Ptr("<tenant id>"),
// UserAssignedIdentities: map[string]*armcontainerinstance.UserAssignedIdentities{
// "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity": &armcontainerinstance.UserAssignedIdentities{
// ClientID: to.Ptr("<client id>"),
// PrincipalID: to.Ptr("<principal id>"),
// },
// },
// },
// Location: to.Ptr("eastus2"),
// Properties: &armcontainerinstance.ContainerGroupPropertiesProperties{
// Containers: []*armcontainerinstance.Container{
// {
// Name: to.Ptr("demo1"),
// Properties: &armcontainerinstance.ContainerProperties{
// Command: []*string{
// },
// EnvironmentVariables: []*armcontainerinstance.EnvironmentVariable{
// },
// Image: to.Ptr("nginx"),
// Ports: []*armcontainerinstance.ContainerPort{
// {
// Port: to.Ptr[int32](80),
// },
// },
// Resources: &armcontainerinstance.ResourceRequirements{
// Requests: &armcontainerinstance.ResourceRequests{
// CPU: to.Ptr[float64](1),
// MemoryInGB: to.Ptr[float64](1.5),
// },
// },
// },
// },
// },
// EncryptionProperties: &armcontainerinstance.EncryptionProperties{
// Identity: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity"),
// KeyName: to.Ptr("test-key"),
// KeyVersion: to.Ptr("<key version>"),
// VaultBaseURL: to.Ptr("https://testkeyvault.vault.azure.net/"),
// },
// ImageRegistryCredentials: []*armcontainerinstance.ImageRegistryCredential{
// },
// InitContainers: []*armcontainerinstance.InitContainerDefinition{
// },
// InstanceView: &armcontainerinstance.ContainerGroupPropertiesInstanceView{
// Events: []*armcontainerinstance.Event{
// },
// State: to.Ptr("Pending"),
// },
// IPAddress: &armcontainerinstance.IPAddress{
// Type: to.Ptr(armcontainerinstance.ContainerGroupIPAddressTypePublic),
// Ports: []*armcontainerinstance.Port{
// {
// Port: to.Ptr[int32](80),
// Protocol: to.Ptr(armcontainerinstance.ContainerGroupNetworkProtocolTCP),
// },
// },
// },
// IsCreatedFromStandbyPool: to.Ptr(false),
// OSType: to.Ptr(armcontainerinstance.OperatingSystemTypesLinux),
// ProvisioningState: to.Ptr("Pending"),
// SKU: to.Ptr(armcontainerinstance.ContainerGroupSKUStandard),
// },
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
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-07-01/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);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"identity": {
"type": "UserAssigned",
"tenantId": "<tenant id>",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity": {
"clientId": "<client id>",
"principalId": "<principal id>"
}
}
},
"location": "eastus2",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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": [],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Pending"
},
"ipAddress": {
"type": "Public",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Pending",
"sku": "Standard"
}
}
{
"name": "demo1",
"type": "Microsoft.ContainerInstance/containerGroups",
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ContainerInstance/containerGroups/demo1",
"identity": {
"type": "UserAssigned",
"tenantId": "<tenant id>",
"userAssignedIdentities": {
"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity": {
"clientId": "<client id>",
"principalId": "<principal id>"
}
}
},
"location": "eastus2",
"properties": {
"containers": [
{
"name": "demo1",
"properties": {
"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": [],
"initContainers": [],
"instanceView": {
"events": [],
"state": "Pending"
},
"ipAddress": {
"type": "Public",
"ports": [
{
"port": 80,
"protocol": "TCP"
}
]
},
"isCreatedFromStandbyPool": false,
"osType": "Linux",
"provisioningState": "Running",
"sku": "Standard"
}
}
Definitions
AzureFileVolume
Object
The properties of the Azure File volume. Azure File shares are mounted as volumes.
| Name |
Type |
Description |
|
readOnly
|
boolean
|
The flag indicating whether the Azure File shared mounted as a volume is read-only.
|
|
shareName
|
string
|
The name of the Azure File share to be mounted as a volume.
|
|
storageAccountKey
|
string
(password)
|
The storage account access key used to access the Azure File share.
|
|
storageAccountKeyReference
|
string
|
The reference to the storage account access key used to access the Azure File share.
|
|
storageAccountName
|
string
|
The name of the storage account that contains the Azure File share.
|
|
userManagedIdentityClientId
|
string
|
The client id of the user-assigned managed identity that has access to the Azure File share.
|
CloudError
Object
An error response from the Container Instance service.
| Name |
Type |
Description |
|
error
|
CloudErrorBody
|
An error response from the Container Instance service.
|
CloudErrorBody
Object
An error response from the Container Instance service.
| Name |
Type |
Description |
|
code
|
string
|
An identifier for the error. Codes are invariant and are intended to be consumed programmatically.
|
|
details
|
CloudErrorBody[]
|
A list of additional details about the error.
|
|
message
|
string
|
A message describing the error, intended to be suitable for display in a user interface.
|
|
target
|
string
|
The target of the particular error. For example, the name of the property in error.
|
ConfidentialComputeProperties
Object
The properties for confidential container group
| Name |
Type |
Description |
|
ccePolicy
|
string
|
The base64 encoded confidential compute enforcement policy
|
ConfigMap
Object
The container config map.
| Name |
Type |
Description |
|
keyValuePairs
|
object
|
The key value pairs dictionary in the config map.
|
Container
Object
A container instance.
| Name |
Type |
Description |
|
name
|
string
|
The user-provided name of the container instance.
|
|
properties.command
|
string[]
|
The commands to execute within the container instance in exec form.
|
|
properties.configMap
|
ConfigMap
|
The config map.
|
|
properties.environmentVariables
|
EnvironmentVariable[]
|
The environment variables to set in the container instance.
|
|
properties.image
|
string
|
The name of the image used to create the container instance.
|
|
properties.instanceView
|
ContainerPropertiesInstanceView
|
The instance view of the container instance. Only valid in response.
|
|
properties.livenessProbe
|
ContainerProbe
|
The liveness probe.
|
|
properties.ports
|
ContainerPort[]
|
The exposed ports on the container instance.
|
|
properties.readinessProbe
|
ContainerProbe
|
The readiness probe.
|
|
properties.resources
|
ResourceRequirements
|
The resource requirements of the container instance.
|
|
properties.securityContext
|
SecurityContextDefinition
|
The container security properties.
|
|
properties.volumeMounts
|
VolumeMount[]
|
The volume mounts available to the container instance.
|
ContainerExec
Object
The container execution command, for liveness or readiness probe
| Name |
Type |
Description |
|
command
|
string[]
|
The commands to execute within the container.
|
ContainerGroup
Object
A container group.
| Name |
Type |
Description |
|
id
|
string
(arm-id)
|
Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}"
|
|
identity
|
ContainerGroupIdentity
|
The identity of the container group, if configured.
|
|
location
|
string
|
The resource location of the container group.
|
|
name
|
string
|
The name of the resource
|
|
properties.confidentialComputeProperties
|
ConfidentialComputeProperties
|
The properties for confidential container group
|
|
properties.containerGroupProfile
|
ContainerGroupProfileReferenceDefinition
|
The reference container group profile properties.
|
|
properties.containers
|
Container[]
|
The containers within the container group.
|
|
properties.diagnostics
|
ContainerGroupDiagnostics
|
The diagnostic information for a container group.
|
|
properties.dnsConfig
|
DnsConfiguration
|
The DNS config information for a container group.
|
|
properties.encryptionProperties
|
EncryptionProperties
|
The encryption properties for a container group.
|
|
properties.extensions
|
DeploymentExtensionSpec[]
|
extensions used by virtual kubelet
|
|
properties.identityAcls
|
IdentityAcls
|
The access control levels of the identities.
|
|
properties.imageRegistryCredentials
|
ImageRegistryCredential[]
|
The image registry credentials by which the container group is created from.
|
|
properties.initContainers
|
InitContainerDefinition[]
|
The init containers for a container group.
|
|
properties.instanceView
|
ContainerGroupPropertiesPropertiesInstanceView
|
The instance view of the container group. Only valid in response.
|
|
properties.ipAddress
|
IpAddress
|
The IP address type of the container group.
|
|
properties.isCreatedFromStandbyPool
|
boolean
|
The flag to determine whether the container group is created from standby pool.
|
|
properties.osType
|
OperatingSystemTypes
|
The operating system type required by the containers in the container group.
|
|
properties.priority
|
ContainerGroupPriority
|
The priority of the container group.
|
|
properties.provisioningState
|
string
|
The provisioning state of the container group. This only appears in the response.
|
|
properties.restartPolicy
|
ContainerGroupRestartPolicy
|
Restart policy for all containers within the container group.
Always Always restart
OnFailure Restart on failure
Never Never restart
|
|
properties.secretReferences
|
SecretReference[]
|
The secret references that will be referenced within the container group.
|
|
properties.sku
|
ContainerGroupSku
|
The SKU for a container group.
|
|
properties.standbyPoolProfile
|
StandbyPoolProfileDefinition
|
The reference standby pool profile properties.
|
|
properties.subnetIds
|
ContainerGroupSubnetId[]
|
The subnet resource IDs for a container group.
|
|
properties.volumes
|
Volume[]
|
The list of volumes that can be mounted by containers in this container group.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
tags
|
object
|
The resource tags.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
|
zones
|
string[]
|
The availability zones.
|
ContainerGroupDiagnostics
Object
Container group diagnostic information.
| Name |
Type |
Description |
|
logAnalytics
|
LogAnalytics
|
Container group log analytics information.
|
ContainerGroupIdentity
Object
Identity for the container group.
| Name |
Type |
Description |
|
principalId
|
string
|
The principal id of the container group identity. This property will only be provided for a system assigned identity.
|
|
tenantId
|
string
|
The tenant id associated with the container group. This property will only be provided for a system assigned identity.
|
|
type
|
ResourceIdentityType
|
The type of identity used for the container group. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the container group.
|
|
userAssignedIdentities
|
<string,
UserAssignedIdentities>
|
The list of user identities associated with the container group.
|
ContainerGroupIpAddressType
Enumeration
Specifies if the IP is exposed to the public internet or private VNET.
| Value |
Description |
|
Public
|
Public
|
|
Private
|
Private
|
ContainerGroupNetworkProtocol
Enumeration
The protocol associated with the port.
| Value |
Description |
|
TCP
|
TCP
|
|
UDP
|
UDP
|
ContainerGroupPriority
Enumeration
The priority of the container group.
| Value |
Description |
|
Regular
|
Regular
|
|
Spot
|
Spot
|
ContainerGroupProfileReferenceDefinition
Object
The container group profile reference.
| Name |
Type |
Description |
|
id
|
string
(arm-id)
|
The container group profile reference id.This will be an ARM resource id in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroupProfiles/{containerGroupProfileName}'.
|
|
revision
|
integer
(int32)
|
The container group profile reference revision.
|
ContainerGroupPropertiesPropertiesInstanceView
Object
The instance view of the container group. Only valid in response.
| Name |
Type |
Description |
|
events
|
Event[]
|
The events of this container group.
|
|
state
|
string
|
The state of the container group. Only valid in response.
|
ContainerGroupRestartPolicy
Enumeration
Restart policy for all containers within the container group.
Always Always restart
OnFailure Restart on failure
Never Never restart
| Value |
Description |
|
Always
|
Always
|
|
OnFailure
|
OnFailure
|
|
Never
|
Never
|
ContainerGroupSku
Enumeration
The container group SKU.
| Value |
Description |
|
NotSpecified
|
NotSpecified
|
|
Standard
|
Standard
|
|
Dedicated
|
Dedicated
|
|
Confidential
|
Confidential
|
ContainerGroupSubnetId
Object
Container group subnet information.
| Name |
Type |
Description |
|
id
|
string
|
Resource ID of virtual network and subnet.
|
|
name
|
string
|
Friendly name for the subnet.
|
ContainerHttpGet
Object
The container Http Get settings, for liveness or readiness probe
| Name |
Type |
Description |
|
httpHeaders
|
HttpHeader[]
|
The HTTP headers.
|
|
path
|
string
|
The path to probe.
|
|
port
|
integer
(int32)
|
The port number to probe.
|
|
scheme
|
Scheme
|
The scheme.
|
ContainerNetworkProtocol
Enumeration
The protocol associated with the port.
| Value |
Description |
|
TCP
|
TCP
|
|
UDP
|
UDP
|
ContainerPort
Object
The port exposed on the container instance.
| Name |
Type |
Description |
|
port
|
integer
(int32)
|
The port number exposed within the container group.
|
|
protocol
|
ContainerNetworkProtocol
|
The protocol associated with the port.
|
ContainerProbe
Object
The container probe, for liveness or readiness
| Name |
Type |
Description |
|
exec
|
ContainerExec
|
The execution command to probe
|
|
failureThreshold
|
integer
(int32)
|
The failure threshold.
|
|
httpGet
|
ContainerHttpGet
|
The Http Get settings to probe
|
|
initialDelaySeconds
|
integer
(int32)
|
The initial delay seconds.
|
|
periodSeconds
|
integer
(int32)
|
The period seconds.
|
|
successThreshold
|
integer
(int32)
|
The success threshold.
|
|
timeoutSeconds
|
integer
(int32)
|
The timeout seconds.
|
ContainerPropertiesInstanceView
Object
The instance view of the container instance. Only valid in response.
| Name |
Type |
Description |
|
currentState
|
ContainerState
|
Current container instance state.
|
|
events
|
Event[]
|
The events of the container instance.
|
|
previousState
|
ContainerState
|
Previous container instance state.
|
|
restartCount
|
integer
(int32)
|
The number of times that the container instance has been restarted.
|
ContainerState
Object
The container instance state.
| Name |
Type |
Description |
|
detailStatus
|
string
|
The human-readable status of the container instance state.
|
|
exitCode
|
integer
(int32)
|
The container instance exit codes correspond to those from the docker run command.
|
|
finishTime
|
string
(date-time)
|
The date-time when the container instance state finished.
|
|
startTime
|
string
(date-time)
|
The date-time when the container instance state started.
|
|
state
|
string
|
The state of the container instance.
|
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
DeploymentExtensionSpec
Object
Extension sidecars to be added to the deployment.
| Name |
Type |
Description |
|
name
|
string
|
Name of the extension.
|
|
properties.extensionType
|
string
|
Type of extension to be added.
|
|
properties.protectedSettings
|
management.azure.com.container-instances.containergroups.createorupdate
|
Protected settings for the extension.
|
|
properties.settings
|
management.azure.com.container-instances.containergroups.createorupdate
|
Settings for the extension.
|
|
properties.version
|
string
|
Version of the extension being used.
|
DnsConfiguration
Object
DNS configuration for the container group.
| Name |
Type |
Description |
|
nameServers
|
string[]
|
The DNS servers for the container group.
|
|
options
|
string
|
The DNS options for the container group.
|
|
searchDomains
|
string
|
The DNS search domains for hostname lookup in the container group.
|
DnsNameLabelReusePolicy
Enumeration
The value representing the security enum. The 'Unsecure' value is the default value if not selected and means the object's domain name label is not secured against subdomain takeover. The 'TenantReuse' value is the default value if selected and means the object's domain name label can be reused within the same tenant. The 'SubscriptionReuse' value means the object's domain name label can be reused within the same subscription. The 'ResourceGroupReuse' value means the object's domain name label can be reused within the same resource group. The 'NoReuse' value means the object's domain name label cannot be reused within the same resource group, subscription, or tenant.
| Value |
Description |
|
Unsecure
|
Unsecure
|
|
TenantReuse
|
TenantReuse
|
|
SubscriptionReuse
|
SubscriptionReuse
|
|
ResourceGroupReuse
|
ResourceGroupReuse
|
|
Noreuse
|
Noreuse
|
EncryptionProperties
Object
The container group encryption properties.
| Name |
Type |
Description |
|
identity
|
string
|
The keyvault managed identity.
|
|
keyName
|
string
|
The encryption key name.
|
|
keyVersion
|
string
|
The encryption key version.
|
|
vaultBaseUrl
|
string
|
The keyvault base url.
|
EnvironmentVariable
Object
The environment variable to set within the container instance.
| Name |
Type |
Description |
|
name
|
string
|
The name of the environment variable.
|
|
secureValue
|
string
(password)
|
The value of the secure environment variable.
|
|
secureValueReference
|
string
|
The reference of the secure environment variable.
|
|
value
|
string
|
The value of the environment variable.
|
Event
Object
A container group or container instance event.
| Name |
Type |
Description |
|
count
|
integer
(int32)
|
The count of the event.
|
|
firstTimestamp
|
string
(date-time)
|
The date-time of the earliest logged event.
|
|
lastTimestamp
|
string
(date-time)
|
The date-time of the latest logged event.
|
|
message
|
string
|
The event message.
|
|
name
|
string
|
The event name.
|
|
type
|
string
|
The event type.
|
GitRepoVolume
Object
Represents a volume that is populated with the contents of a git repository
| Name |
Type |
Description |
|
directory
|
string
|
Target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name.
|
|
repository
|
string
|
Repository URL
|
|
revision
|
string
|
Commit hash for the specified revision.
|
GpuResource
Object
The GPU resource.
| Name |
Type |
Description |
|
count
|
integer
(int32)
|
The count of the GPU resource.
|
|
sku
|
GpuSku
|
The SKU of the GPU resource.
|
GpuSku
Enumeration
The SKU of the GPU resource.
| Value |
Description |
|
K80
|
K80
|
|
P100
|
P100
|
|
V100
|
V100
|
Object
The HTTP header.
| Name |
Type |
Description |
|
name
|
string
|
The header name.
|
|
value
|
string
|
The header value.
|
IdentityAccessControl
Object
The access control for an identity
| Name |
Type |
Description |
|
access
|
IdentityAccessLevel
|
The access level of the identity.
|
|
identity
|
string
(arm-id)
|
An identity.
|
IdentityAccessLevel
Enumeration
The access level of an identity.
| Value |
Description |
|
All
|
All
|
|
System
|
System
|
|
User
|
User
|
IdentityAcls
Object
The access control levels of the identities.
ImageRegistryCredential
Object
Image registry credential.
| Name |
Type |
Description |
|
identity
|
string
|
The identity for the private registry.
|
|
identityUrl
|
string
|
The identity URL for the private registry.
|
|
password
|
string
(password)
|
The password for the private registry.
|
|
passwordReference
|
string
|
The reference for the private registry password.
|
|
server
|
string
|
The Docker image registry server without a protocol such as "http" and "https".
|
|
username
|
string
|
The username for the private registry.
|
InitContainerDefinition
Object
The init container definition.
| Name |
Type |
Description |
|
name
|
string
|
The name for the init container.
|
|
properties.command
|
string[]
|
The command to execute within the init container in exec form.
|
|
properties.environmentVariables
|
EnvironmentVariable[]
|
The environment variables to set in the init container.
|
|
properties.image
|
string
|
The image of the init container.
|
|
properties.instanceView
|
InitContainerPropertiesDefinitionInstanceView
|
The instance view of the init container. Only valid in response.
|
|
properties.securityContext
|
SecurityContextDefinition
|
The container security properties.
|
|
properties.volumeMounts
|
VolumeMount[]
|
The volume mounts available to the init container.
|
InitContainerPropertiesDefinitionInstanceView
Object
The instance view of the init container. Only valid in response.
| Name |
Type |
Description |
|
currentState
|
ContainerState
|
The current state of the init container.
|
|
events
|
Event[]
|
The events of the init container.
|
|
previousState
|
ContainerState
|
The previous state of the init container.
|
|
restartCount
|
integer
(int32)
|
The number of times that the init container has been restarted.
|
IpAddress
Object
IP address for the container group.
| Name |
Type |
Default value |
Description |
|
autoGeneratedDomainNameLabelScope
|
DnsNameLabelReusePolicy
|
Unsecure
|
The value representing the security enum. The 'Unsecure' value is the default value if not selected and means the object's domain name label is not secured against subdomain takeover. The 'TenantReuse' value is the default value if selected and means the object's domain name label can be reused within the same tenant. The 'SubscriptionReuse' value means the object's domain name label can be reused within the same subscription. The 'ResourceGroupReuse' value means the object's domain name label can be reused within the same resource group. The 'NoReuse' value means the object's domain name label cannot be reused within the same resource group, subscription, or tenant.
|
|
dnsNameLabel
|
string
|
|
The Dns name label for the IP.
|
|
fqdn
|
string
|
|
The FQDN for the IP.
|
|
ip
|
string
|
|
The IP exposed to the public internet.
|
|
ports
|
Port[]
|
|
The list of ports exposed on the container group.
|
|
type
|
ContainerGroupIpAddressType
|
|
Specifies if the IP is exposed to the public internet or private VNET.
|
LogAnalytics
Object
Container group log analytics information.
| Name |
Type |
Description |
|
logType
|
LogAnalyticsLogType
|
The log type to be used.
|
|
metadata
|
object
|
Metadata for log analytics.
|
|
workspaceId
|
string
|
The workspace id for log analytics
|
|
workspaceKey
|
string
(password)
|
The workspace key for log analytics
|
|
workspaceResourceId
|
string
(password)
|
The workspace resource id for log analytics
|
LogAnalyticsLogType
Enumeration
The log type to be used.
| Value |
Description |
|
ContainerInsights
|
ContainerInsights
|
|
ContainerInstanceLogs
|
ContainerInstanceLogs
|
OperatingSystemTypes
Enumeration
The operating system type required by the containers in the container group.
| Value |
Description |
|
Windows
|
Windows
|
|
Linux
|
Linux
|
Port
Object
The port exposed on the container group.
ResourceIdentityType
Enumeration
The type of identity used for the container group. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set of user assigned identities. The type 'None' will remove any identities from the container group.
| Value |
Description |
|
SystemAssigned
|
SystemAssigned
|
|
UserAssigned
|
UserAssigned
|
|
SystemAssigned, UserAssigned
|
SystemAssigned, UserAssigned
|
|
None
|
None
|
ResourceLimits
Object
The resource limits.
| Name |
Type |
Description |
|
cpu
|
number
(double)
|
The CPU limit of this container instance.
|
|
gpu
|
GpuResource
|
The GPU limit of this container instance.
|
|
memoryInGB
|
number
(double)
|
The memory limit in GB of this container instance.
|
ResourceRequests
Object
The resource requests.
| Name |
Type |
Description |
|
cpu
|
number
(double)
|
The CPU request of this container instance.
|
|
gpu
|
GpuResource
|
The GPU request of this container instance.
|
|
memoryInGB
|
number
(double)
|
The memory request in GB of this container instance.
|
ResourceRequirements
Object
The resource requirements.
| Name |
Type |
Description |
|
limits
|
ResourceLimits
|
The resource limits of this container instance.
|
|
requests
|
ResourceRequests
|
The resource requests of this container instance.
|
Scheme
Enumeration
The scheme.
| Value |
Description |
|
http
|
http
|
|
https
|
https
|
SecretReference
Object
A secret reference
| Name |
Type |
Description |
|
identity
|
string
(arm-id)
|
The ARM resource id of the managed identity that has access to the secret in the key vault
|
|
name
|
string
|
The identifier of the secret reference
|
|
secretReferenceUri
|
string
(uri)
|
The URI to the secret in key vault
|
SecurityContextCapabilitiesDefinition
Object
The capabilities to add or drop from a container.
| Name |
Type |
Description |
|
add
|
string[]
|
The capabilities to add to the container.
|
|
drop
|
string[]
|
The capabilities to drop from the container.
|
SecurityContextDefinition
Object
The security context for the container.
| Name |
Type |
Description |
|
allowPrivilegeEscalation
|
boolean
|
A boolean value indicating whether the init process can elevate its privileges
|
|
capabilities
|
SecurityContextCapabilitiesDefinition
|
The capabilities to add or drop from a container.
|
|
privileged
|
boolean
|
The flag to determine if the container permissions is elevated to Privileged.
|
|
runAsGroup
|
integer
(int32)
|
Sets the User GID for the container.
|
|
runAsUser
|
integer
(int32)
|
Sets the User UID for the container.
|
|
seccompProfile
|
string
|
a base64 encoded string containing the contents of the JSON in the seccomp profile
|
StandbyPoolProfileDefinition
Object
The standby pool profile reference.
| Name |
Type |
Description |
|
failContainerGroupCreateOnReuseFailure
|
boolean
|
The flag to determine whether ACI should fail the create request if the container group can not be obtained from standby pool.
|
|
id
|
string
(arm-id)
|
The standby pool profile reference id.This will be an ARM resource id in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StandbyPool/standbyContainerGroupPools/{standbyPoolName}'.
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|
UserAssignedIdentities
Object
The list of user identities associated with the container group. The user identity dictionary key references will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'.
| Name |
Type |
Description |
|
clientId
|
string
|
The client id of user assigned identity.
|
|
principalId
|
string
|
The principal id of user assigned identity.
|
Volume
Object
The properties of the volume.
| Name |
Type |
Description |
|
azureFile
|
AzureFileVolume
|
The Azure File volume.
|
|
emptyDir
|
management.azure.com.container-instances.containergroups.createorupdate
|
The empty directory volume.
|
|
gitRepo
|
GitRepoVolume
|
The git repo volume.
|
|
name
|
string
|
The name of the volume.
|
|
secret
|
object
|
Defines files for a secret volume. Dictionary keys are file names and values are Base64-encoded secret data used as file contents. The values are sensitive, and the service does not return the contents of this property in GET responses.
|
|
secretReference
|
object
|
Defines files for a secret reference volume. Dictionary keys are file names and values identify entries in the container group's secretReferences collection. This property contains reference names rather than secret values.
|
VolumeMount
Object
The properties of the volume mount.
| Name |
Type |
Description |
|
mountPath
|
string
|
The path within the container where the volume should be mounted. Must not contain colon (:).
|
|
name
|
string
|
The name of the volume mount.
|
|
readOnly
|
boolean
|
The flag indicating whether the volume mount is read-only.
|