Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
New-AzContainerGroup
- Module:
- Az.ContainerInstance Module
Create or update container groups with specified configurations.
Syntax
CreateExpanded (Default)
New-AzContainerGroup
-Name <String>
-ResourceGroupName <String>
-Container <IContainer[]>
-Location <String>
[-SubscriptionId <String>]
[-OSType <String>]
[-ConfidentialComputePropertyCcePolicy <String>]
[-ContainerGroupProfileId <String>]
[-ContainerGroupProfileRevision <Int32>]
[-DnsConfigNameServer <String[]>]
[-DnsConfigOption <String>]
[-DnsConfigSearchDomain <String>]
[-EnableSystemAssignedIdentity]
[-EncryptionPropertyIdentity <String>]
[-EncryptionPropertyKeyName <String>]
[-EncryptionPropertyKeyVersion <String>]
[-EncryptionPropertyVaultBaseUrl <String>]
[-Extension <IDeploymentExtensionSpec[]>]
[-IPAddressAutoGeneratedDomainNameLabelScope <String>]
[-IPAddressDnsNameLabel <String>]
[-IPAddressIP <String>]
[-IPAddressPort <IPort[]>]
[-IPAddressType <String>]
[-ImageRegistryCredential <IImageRegistryCredential[]>]
[-InitContainer <IInitContainerDefinition[]>]
[-LogAnalyticLogType <String>]
[-LogAnalyticMetadata <Hashtable>]
[-LogAnalyticWorkspaceId <String>]
[-LogAnalyticWorkspaceKey <String>]
[-LogAnalyticWorkspaceResourceId <String>]
[-RestartPolicy <String>]
[-Sku <String>]
[-StandbyPoolProfileFailContainerGroupCreateOnReuseFailure]
[-StandbyPoolProfileId <String>]
[-SubnetId <IContainerGroupSubnetId[]>]
[-Tag <Hashtable>]
[-UserAssignedIdentity <String[]>]
[-Volume <IVolume[]>]
[-Zone <String[]>]
[-Priority <String>]
[-DefaultProfile <PSObject>]
[-AsJob]
[-NoWait]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
CreateViaJsonFilePath
New-AzContainerGroup
-Name <String>
-ResourceGroupName <String>
-JsonFilePath <String>
[-SubscriptionId <String>]
[-DefaultProfile <PSObject>]
[-AsJob]
[-NoWait]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
CreateViaJsonString
New-AzContainerGroup
-Name <String>
-ResourceGroupName <String>
-JsonString <String>
[-SubscriptionId <String>]
[-DefaultProfile <PSObject>]
[-AsJob]
[-NoWait]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Create or update container groups with specified configurations.
Examples
Example 1: Create a container group with a container instance and request a public IP address with opening ports
$port1 = New-AzContainerInstancePortObject -Port 8000 -Protocol TCP
$port2 = New-AzContainerInstancePortObject -Port 8001 -Protocol TCP
$container = New-AzContainerInstanceObject -Name test-container -Image nginx -RequestCpu 1 -RequestMemoryInGb 1.5 -Port @($port1, $port2)
$containerGroup = New-AzContainerGroup -ResourceGroupName test-rg -Name test-cg -Location eastus -Container $container -OsType Linux -RestartPolicy "Never" -IpAddressType Public
Location Name Zone ResourceGroupName
-------- ---- ---- -----------------
eastus test-cg test-rg
This commands creates a container group with a container instance, whose image is latest nginx, and requests a public IP address with opening port 8000 and 8001.
Example 2: Create container group and runs a custom script inside the container.
$pwd = ConvertTo-SecureString -String "****" -AsPlainText -Force
$env1 = New-AzContainerInstanceEnvironmentVariableObject -Name "env1" -Value "value1"
$env2 = New-AzContainerInstanceEnvironmentVariableObject -Name "env2" -SecureValue $pwd
$container = New-AzContainerInstanceObject -Name test-container -Image alpine -Command "/bin/sh -c myscript.sh" -EnvironmentVariable @($env1, $env2)
$containerGroup = New-AzContainerGroup -ResourceGroupName test-rg -Name test-cg -Location eastus -Container $container -OsType Linux
Location Name Zone ResourceGroupName
-------- ---- ---- -----------------
eastus test-cg test-rg
This commands creates a container group and runs a custom script inside the container.
Example 3: Create a run-to-completion container group
$container = New-AzContainerInstanceObject -Name test-container -Image alpine -Command "echo hello"
$containerGroup = New-AzContainerGroup -ResourceGroupName test-rg -Name test-cg -Location eastus -Container $container -OsType Linux
Location Name Zone ResourceGroupName
-------- ---- ---- -----------------
eastus test-cg test-rg
This commands creates a container group which prints out 'hello' and stops.
Example 4: Create a container group with a container instance using image nginx in Azure Container Registry
$pwd = ConvertTo-SecureString -String "****" -AsPlainText -Force
$container = New-AzContainerInstanceObject -Name test-container -Image myacr.azurecr.io/nginx:latest
$imageRegistryCredential = New-AzContainerGroupImageRegistryCredentialObject -Server "myacr.azurecr.io" -Username "username" -Password $pwd
$containerGroup = New-AzContainerGroup -ResourceGroupName test-rg -Name test-cg -Location eastus -Container $container -ImageRegistryCredential $imageRegistryCredential
Location Name Zone ResourceGroupName
-------- ---- ---- -----------------
eastus test-cg test-rg
This commands creates a container group with a container instance, whose image is nginx in Azure Container Registry.
Example 5: Create a container group with a container instance using image nginx in custom container image Registry
$pwd = ConvertTo-SecureString -String "****" -AsPlainText -Force
$container = New-AzContainerInstanceObject -Name test-container -Image myserver.com/nginx:latest
$imageRegistryCredential = New-AzContainerGroupImageRegistryCredentialObject -Server "myserver.com" -Username "username" -Password $pwd
$containerGroup = New-AzContainerGroup -ResourceGroupName test-rg -Name test-cg -Location eastus -Container $container -ImageRegistryCredential $imageRegistryCredential
Location Name Zone ResourceGroupName
-------- ---- ---- -----------------
eastus test-cg test-rg
This commands creates a container group with a container instance, whose image is a custom image from a custom container image registry.
Example 6: Create a container group that mounts Azure File volume
$pwd = ConvertTo-SecureString -String "****" -AsPlainText -Force
$volume = New-AzContainerGroupVolumeObject -Name "myvolume" -AzureFileShareName "myshare" -AzureFileStorageAccountName "username" -AzureFileStorageAccountKey $pwd
$mount = New-AzContainerInstanceVolumeMountObject -MountPath "/aci/logs" -Name "myvolume"
$container = New-AzContainerInstanceObject -Name test-container -Image alpine -VolumeMount $mount
$containerGroup = New-AzContainerGroup -ResourceGroupName test-rg -Name test-cg -Location eastus -Container $container -Volume $volume
Location Name Zone ResourceGroupName
-------- ---- ---- -----------------
eastus test-cg test-rg
This commands creates a container group with a container instance, whose image is a custom image from a custom container image registry.
Example 7: Create a container group with system assigned and user assigned identity
$container = New-AzContainerInstanceObject -Name test-container -Image alpine
$containerGroup = New-AzContainerGroup -ResourceGroupName test-rg -Name test-cg -Location eastus -Container $container -EnableSystemAssignedIdentity -UserAssignedIdentity "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}"
Location Name Zone ResourceGroupName
-------- ---- ---- -----------------
eastus test-cg test-rg
This commands creates a container group with system assigned and user assigned identity.
Parameters
-AsJob
Run the command as a job
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ConfidentialComputePropertyCcePolicy
The base64 encoded confidential compute enforcement policy
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
-Container
The containers within the container group.
Parameter properties
| Type: | Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IContainer[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ContainerGroupProfileId
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}'.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ContainerGroupProfileRevision
The container group profile reference revision.
Parameter properties
| Type: | Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DefaultProfile
The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
Parameter properties
| Type: | PSObject |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | AzureRMContext, AzureCredential |
Parameter sets
-DnsConfigNameServer
The DNS servers for the container group.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DnsConfigOption
The DNS options for the container group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-DnsConfigSearchDomain
The DNS search domains for hostname lookup in the container group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EnableSystemAssignedIdentity
Determines whether to enable a system-assigned identity for the resource.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EncryptionPropertyIdentity
The keyvault managed identity.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EncryptionPropertyKeyName
The encryption key name.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EncryptionPropertyKeyVersion
The encryption key version.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-EncryptionPropertyVaultBaseUrl
The keyvault base url.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Extension
extensions used by virtual kubelet
Parameter properties
| Type: | Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IDeploymentExtensionSpec[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ImageRegistryCredential
The image registry credentials by which the container group is created from.
Parameter properties
| Type: | Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IImageRegistryCredential[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-InitContainer
The init containers for a container group.
Parameter properties
| Type: | Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IInitContainerDefinition[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-IPAddressAutoGeneratedDomainNameLabelScope
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.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-IPAddressDnsNameLabel
The Dns name label for the IP.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-IPAddressIP
The IP exposed to the public internet.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-IPAddressPort
The list of ports exposed on the container group.
Parameter properties
| Type: | Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IPort[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-IPAddressType
Specifies if the IP is exposed to the public internet or private VNET.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-JsonFilePath
Path of Json file supplied to the Create operation
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-JsonString
Json string supplied to the Create operation
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Location
The resource location.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-LogAnalyticLogType
The log type to be used.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-LogAnalyticMetadata
Metadata for log analytics.
Parameter properties
| Type: | Hashtable |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-LogAnalyticWorkspaceId
The workspace id for log analytics
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-LogAnalyticWorkspaceKey
The workspace key for log analytics
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-LogAnalyticWorkspaceResourceId
The workspace resource id for log analytics
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Name
The name of the container group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | ContainerGroupName |
Parameter sets
-NoWait
Run the command asynchronously
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-OSType
The operating system type required by the containers in the container group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Priority
The priority of the container group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ResourceGroupName
The name of the resource group. The name is case insensitive.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-RestartPolicy
Restart policy for all containers within the container group.
AlwaysAlways restart-OnFailureRestart on failure-NeverNever restart
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Sku
The SKU for a container group.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-StandbyPoolProfileFailContainerGroupCreateOnReuseFailure
The flag to determine whether ACI should fail the create request if the container group can not be obtained from standby pool.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-StandbyPoolProfileId
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}'.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SubnetId
The subnet resource IDs for a container group.
Parameter properties
| Type: | Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IContainerGroupSubnetId[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-SubscriptionId
The ID of the target subscription. The value must be an UUID.
Parameter properties
| Type: | String |
| Default value: | (Get-AzContext).Subscription.Id |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Tag
The resource tags.
Parameter properties
| Type: | Hashtable |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-UserAssignedIdentity
The array of user assigned identities associated with the resource. The elements in array will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.'
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Volume
The list of volumes that can be mounted by containers in this container group.
Parameter properties
| Type: | Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IVolume[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
-Zone
The zones for the container group.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Outputs
Microsoft.Azure.PowerShell.Cmdlets.ContainerInstance.Models.IContainerGroup
Azure PowerShell
Feedback
Was this page helpful?
