< Back
New-AzureRmContainerGroup
Post
NAME New-AzureRmContainerGroup
SYNOPSIS
Creates a container group.
SYNTAX
New-AzureRmContainerGroup [-ResourceGroupName] <String> [-Name] <String> [-Image] <String> -AzureFileVolumeAccountCredential <PSCredential>
-AzureFileVolumeMountPath <String> -AzureFileVolumeShareName <String> [-Command <String>] [-Cpu <Int32>] [-DefaultProfile
<IAzureContextContainer>] [-DnsNameLabel <String>] [-EnvironmentVariable <Hashtable>] [-IpAddressType {Public}] [-Location <String>] [-MemoryInGB
<Double>] [-OsType {Linux | Windows}] [-Port <Int32[]>] [-RegistryCredential <PSCredential>] [-RegistryServerDomain <String>] [-RestartPolicy
{Always | Never | OnFailure}] [-Tag <Hashtable>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
The New-AzureRmContainerGroup cmdlets creates a container group.
PARAMETERS
-AzureFileVolumeAccountCredential <PSCredential>
The storage account credential of the Azure File share to mount where the username is the storage account name and the key is the storage
account key.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-AzureFileVolumeMountPath <String>
The mount path for the Azure File volume.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-AzureFileVolumeShareName <String>
The name of the Azure File share to mount.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Command <String>
The command to run in the container.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Cpu <Int32>
The required CPU cores. Default: 1
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DnsNameLabel <String>
The DNS name label for the IP address.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-EnvironmentVariable <Hashtable>
The container environment variables.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Image <String>
The container image.
Required? true
Position? 2
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-IpAddressType <String>
The IP address type.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Location <String>
The container group Location. Default to the location of the resource group.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-MemoryInGB <Double>
The required memory in GB. Default: 1.5
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Name <String>
The container group name.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-OsType <String>
The container OS type. Default: Linux
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Port <Int32[]>
The port(s) to open. Default: [80]
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-RegistryCredential <PSCredential>
The custom container registry credential.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-RegistryServerDomain <String>
The custom container registry login server.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ResourceGroupName <String>
The resource group name.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-RestartPolicy <String>
The container restart policy. Default: Always
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Tag <Hashtable>
{{Fill Tag Description}}
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String
System.Collections.Hashtable
OUTPUTS
Microsoft.Azure.Commands.ContainerInstance.Models.PSContainerGroup
NOTES
Example 1
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName demo -Name mycontainer -Image nginx -OsType Linux -IpAddressType Public -Port @(8000)
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials :
RestartPolicy :
IpAddress : 13.88.10.240
Ports : {8000}
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group using latest nginx image and requests a public IP address with opening port 8000.
Example 2
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName demo -Name mycontainer -Image alpine -OsType Linux -Command "/bin/sh -c myscript.sh"
-EnvironmentVariable @{"env1"="value1";"env2"="value2"}
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials :
RestartPolicy :
IpAddress :
Ports :
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group and runs a custom script inside the container.
Example 3: Creates a run-to-completion container group.
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName demo -Name mycontainer -Image alpine -OsType Linux -Command "echo hello" -RestartPolicy Never
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials :
RestartPolicy :
IpAddress :
Ports :
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group which prints out 'hello' and stops.
Example 4: Creates a container group using image in Azure Container Registry
PS C:\\> $secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
PS C:\\> $mycred = New-Object System.Management.Automation.PSCredential ("myacr", $secpasswd)
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName demo -Name mycontainer -Image myacr.azurecr.io/nginx:latest -IpAddressType Public
-RegistryCredential $mycred
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials : {myacr}
RestartPolicy :
IpAddress : 13.88.10.240
Ports : {80}
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group using a nginx image in Azure Container Registry.
Example 5: Creates a container group using image in custom container image registry
PS C:\\> $secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
PS C:\\> $mycred = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName MyResourceGroup -Name MyContainer -Image myserver.com/myimage:latest -RegistryServer
myserver.com -RegistryCredential $mycred
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials : {myserver.com}
RestartPolicy :
IpAddress : 13.88.10.240
Ports : {80}
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group using a custom image from a custom container image registry.
Example 6: Creates a container group that mounts Azure File volume
PS C:\\> $secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
PS C:\\> $mycred = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName MyResourceGroup -Name MyContainer -Image alpine -AzureFileVolumeShareName myshare
-AzureFileVolumeAccountKey $mycred -AzureFileVolumeMountPath /mnt/azfile
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials : {myserver.com}
RestartPolicy :
IpAddress : 13.88.10.240
Ports : {80}
OsType : Linux
Volumes : {AzureFile}
State : Running
Events : {}
This commands creates a container group that mounts the provided Azure File share to `/mnt/azfile`.
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... ainergroup
SYNOPSIS
Creates a container group.
SYNTAX
New-AzureRmContainerGroup [-ResourceGroupName] <String> [-Name] <String> [-Image] <String> -AzureFileVolumeAccountCredential <PSCredential>
-AzureFileVolumeMountPath <String> -AzureFileVolumeShareName <String> [-Command <String>] [-Cpu <Int32>] [-DefaultProfile
<IAzureContextContainer>] [-DnsNameLabel <String>] [-EnvironmentVariable <Hashtable>] [-IpAddressType {Public}] [-Location <String>] [-MemoryInGB
<Double>] [-OsType {Linux | Windows}] [-Port <Int32[]>] [-RegistryCredential <PSCredential>] [-RegistryServerDomain <String>] [-RestartPolicy
{Always | Never | OnFailure}] [-Tag <Hashtable>] [-Confirm] [-WhatIf] [<CommonParameters>]
DESCRIPTION
The New-AzureRmContainerGroup cmdlets creates a container group.
PARAMETERS
-AzureFileVolumeAccountCredential <PSCredential>
The storage account credential of the Azure File share to mount where the username is the storage account name and the key is the storage
account key.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-AzureFileVolumeMountPath <String>
The mount path for the Azure File volume.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-AzureFileVolumeShareName <String>
The name of the Azure File share to mount.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Command <String>
The command to run in the container.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Cpu <Int32>
The required CPU cores. Default: 1
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DefaultProfile <IAzureContextContainer>
The credentials, account, tenant, and subscription used for communication with azure.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-DnsNameLabel <String>
The DNS name label for the IP address.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-EnvironmentVariable <Hashtable>
The container environment variables.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Image <String>
The container image.
Required? true
Position? 2
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-IpAddressType <String>
The IP address type.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Location <String>
The container group Location. Default to the location of the resource group.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-MemoryInGB <Double>
The required memory in GB. Default: 1.5
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Name <String>
The container group name.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-OsType <String>
The container OS type. Default: Linux
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Port <Int32[]>
The port(s) to open. Default: [80]
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-RegistryCredential <PSCredential>
The custom container registry credential.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-RegistryServerDomain <String>
The custom container registry login server.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-ResourceGroupName <String>
The resource group name.
Required? true
Position? 0
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-RestartPolicy <String>
The container restart policy. Default: Always
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Tag <Hashtable>
{{Fill Tag Description}}
Required? false
Position? named
Default value None
Accept pipeline input? True (ByPropertyName)
Accept wildcard characters? false
-Confirm [<SwitchParameter>]
Prompts you for confirmation before running the cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-WhatIf [<SwitchParameter>]
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
System.String
System.Collections.Hashtable
OUTPUTS
Microsoft.Azure.Commands.ContainerInstance.Models.PSContainerGroup
NOTES
Example 1
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName demo -Name mycontainer -Image nginx -OsType Linux -IpAddressType Public -Port @(8000)
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials :
RestartPolicy :
IpAddress : 13.88.10.240
Ports : {8000}
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group using latest nginx image and requests a public IP address with opening port 8000.
Example 2
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName demo -Name mycontainer -Image alpine -OsType Linux -Command "/bin/sh -c myscript.sh"
-EnvironmentVariable @{"env1"="value1";"env2"="value2"}
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials :
RestartPolicy :
IpAddress :
Ports :
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group and runs a custom script inside the container.
Example 3: Creates a run-to-completion container group.
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName demo -Name mycontainer -Image alpine -OsType Linux -Command "echo hello" -RestartPolicy Never
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials :
RestartPolicy :
IpAddress :
Ports :
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group which prints out 'hello' and stops.
Example 4: Creates a container group using image in Azure Container Registry
PS C:\\> $secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
PS C:\\> $mycred = New-Object System.Management.Automation.PSCredential ("myacr", $secpasswd)
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName demo -Name mycontainer -Image myacr.azurecr.io/nginx:latest -IpAddressType Public
-RegistryCredential $mycred
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials : {myacr}
RestartPolicy :
IpAddress : 13.88.10.240
Ports : {80}
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group using a nginx image in Azure Container Registry.
Example 5: Creates a container group using image in custom container image registry
PS C:\\> $secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
PS C:\\> $mycred = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName MyResourceGroup -Name MyContainer -Image myserver.com/myimage:latest -RegistryServer
myserver.com -RegistryCredential $mycred
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials : {myserver.com}
RestartPolicy :
IpAddress : 13.88.10.240
Ports : {80}
OsType : Linux
Volumes :
State : Running
Events : {}
This commands creates a container group using a custom image from a custom container image registry.
Example 6: Creates a container group that mounts Azure File volume
PS C:\\> $secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
PS C:\\> $mycred = New-Object System.Management.Automation.PSCredential ("username", $secpasswd)
PS C:\\> New-AzureRmContainerGroup -ResourceGroupName MyResourceGroup -Name MyContainer -Image alpine -AzureFileVolumeShareName myshare
-AzureFileVolumeAccountKey $mycred -AzureFileVolumeMountPath /mnt/azfile
ResourceGroupName : demo
Id :
/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroups/mycontainer
Name : mycontainer
Type : Microsoft.ContainerInstance/containerGroups
Location : westus
Tags :
ProvisioningState : Creating
Containers : {mycontainer}
ImageRegistryCredentials : {myserver.com}
RestartPolicy :
IpAddress : 13.88.10.240
Ports : {80}
OsType : Linux
Volumes : {AzureFile}
State : Running
Events : {}
This commands creates a container group that mounts the provided Azure File share to `/mnt/azfile`.
RELATED LINKS
Online Version: https://docs.microsoft.com/en-us/powers ... ainergroup