-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Cmdlet(s)
New-AzureRmContainerGroup
PowerShell Version
5.1.15063.786
Module Version
AzureRM 5.2.0
OS Version
10.0.15063.786
Description
Can't create container with a volume mount from an azure registry image.
Following the example, "Example 6: Creates a container group that mounts Azure File volume," I should be able to create an azure container instance with a mounted azure file volume.
New-AzureRmContainerGroup -ResourceGroupName "myresourcegroup"`
-Name "testlibreoffice" `
-Image "mycontainerregistry.azurecr.io/libreoffice:v1" `
-AzureFileVolumeShareName "storagedemo" `
-AzureFileVolumeAccountCredential $storageCreds `
-AzureFileVolumeMountPath "/storagedemo" `
-OsType "Windows" `
-RestartPolicy "Never" `
-IpAddressType "public" `
-Port @(8100)
This fails with the error:
Please specify valid RegistryCredential
I suspect that the method ContainerGroupCreationParameters.Validate is throwing this exception since my azure container image mycontainerregistry.azurecr.io/libreoffice:v1 contains .azurecr.io/ which is checked in the ContainerGroupCreationParameters.Validate method.
Line 32 in e09abe0
| private const string AcrServerSuffix = ".azurecr.io/"; |
Lines 176 to 181 in e09abe0
| else if (this.ContainerImage.Contains(ContainerGroupCreationParameters.AcrServerSuffix)) | |
| { | |
| if (string.IsNullOrEmpty(this.RegistryUsername) || string.IsNullOrEmpty(this.RegistryPassword)) | |
| { | |
| throw new ArgumentException("Please specify valid RegistryCredential"); | |
| } |
This seems to make sense that I would need credentials to the registry, however adding in -RegistryCredential fails with the error.
Parameter set cannot be resolved using the specified named parameters.
This also follows the examples as they don't provide an option that both takes a RegistryCredential as well as a AzureFileVolumeShare
Is this a bug, or are container instances with volume mounts only supported for images sourced from external public registries?
Debug Output
Without -RegistryCredential
New-AzureRmContainerGroup : Please specify valid RegistryCredential
At C:\Platform\MAIN\Deployment\AzureLibreOffice.ps1:36 char:1
+ New-AzureRmContainerGroup -ResourceGroupName $resourceGroup `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmContainerGroup], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ContainerInstance.NewAzureContainerGroupCommand
DEBUG: AzureQoSEvent: CommandName - New-AzureRmContainerGroup; IsSuccess - False; Duration - 00:00:00.2823020;
Exception - System.ArgumentException: Please specify valid RegistryCredential
at Microsoft.Azure.Commands.ContainerInstance.Models.ContainerGroupCreationParameters.Validate()
at Microsoft.Azure.Commands.ContainerInstance.NewAzureContainerGroupCommand.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 5:39:11 PM - NewAzureContainerGroupCommand end processing.
DEBUG: 5:39:11 PM - NewAzureContainerGroupCommand end processing.
With -RegistryCredential
New-AzureRmContainerGroup : Parameter set cannot be resolved using the specified named parameters.
At C:\Platform\MAIN\Deployment\AzureLibreOffice.ps1:40 char:1
+ New-AzureRmContainerGroup -ResourceGroupName $resourceGroup `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-AzureRmContainerGroup], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.Azure.Commands.ContainerInstance.NewAzureContainerGroupC
ommand
Script/Steps for Reproduction
Without -RegistryCredential
New-AzureRmContainerGroup -ResourceGroupName "myresourcegroup"`
-Name "testlibreoffice" `
-Image "mycontainerregistry.azurecr.io/libreoffice:v1" `
-AzureFileVolumeShareName "storagedemo" `
-AzureFileVolumeAccountCredential $storageCreds `
-AzureFileVolumeMountPath "/storagedemo" `
-OsType "Windows" `
-RestartPolicy "Never" `
-IpAddressType "public" `
-Port @(8100)
With -RegistryCredential
New-AzureRmContainerGroup -ResourceGroupName "myresourcegroup"`
-Name "testlibreoffice" `
-Image "mycontainerregistry.azurecr.io/libreoffice:v1" `
-AzureFileVolumeShareName "storagedemo" `
-AzureFileVolumeAccountCredential $storageCreds `
-AzureFileVolumeMountPath "/storagedemo" `
-OsType "Windows" `
-RestartPolicy "Never" `
-IpAddressType "public" `
-Port @(8100) `
-RegistryCredential $regCred