Skip to content

Commit 6a893ee

Browse files
author
Maddie Clayton
authored
Merge pull request #5689 from yolo3301/fix_reg
Fix for #5506
2 parents e4305cc + 3961eba commit 6a893ee

File tree

7 files changed

+30
-31
lines changed

7 files changed

+30
-31
lines changed

src/ResourceManager/ContainerInstance/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Fix parameter sets issue for container registry and azure file volume mount
2122
* Fix issue with Default Resource Group in CloudShell
2223

2324
## Version 0.2.3

src/ResourceManager/ContainerInstance/Commands.ContainerInstance.Test/ScenarioTests/ContainerInstanceTests.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,22 @@ function Test-AzureRmContainerGroupWithVolumeMount
9999
$resourceGroupName = Get-RandomResourceGroupName
100100
$containerGroupName = Get-RandomContainerGroupName
101101
$location = Get-ProviderLocation "Microsoft.ContainerInstance/ContainerGroups"
102-
$image = "alpine"
102+
$image = "acc.azurecr.io/alpine"
103103
$shareName = "acipstestshare"
104104
$accountName = "acipstest"
105105
$accountKey = "password"
106106
$secureAccountKey = ConvertTo-SecureString $accountKey -AsPlainText -Force
107107
$accountCredential = New-Object System.Management.Automation.PSCredential ($accountName, $secureAccountKey)
108+
$registryUsername = "acc"
109+
$registryPassword = "password"
110+
$secureRegistryPassword = ConvertTo-SecureString $registryPassword -AsPlainText -Force
111+
$registryCredential = New-Object System.Management.Automation.PSCredential ($registryUsername, $secureRegistryPassword)
108112
$mountPath = "/mnt/azfile"
109113

110114
try
111115
{
112116
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location
113-
$containerGroupCreated = New-AzureRmContainerGroup -ResourceGroupName $resourceGroupName -Name $containerGroupName -Image $image -RestartPolicy "Never" -Command "ls $mountPath" -AzureFileVolumeShareName $shareName -AzureFileVolumeAccountCredential $accountCredential -AzureFileVolumeMountPath $mountPath
117+
$containerGroupCreated = New-AzureRmContainerGroup -ResourceGroupName $resourceGroupName -Name $containerGroupName -Image $image -RegistryCredential $registryCredential -RestartPolicy "Never" -Command "ls $mountPath" -AzureFileVolumeShareName $shareName -AzureFileVolumeAccountCredential $accountCredential -AzureFileVolumeMountPath $mountPath
114118

115119
Assert-NotNull $containerGroupCreated.Volumes
116120
Assert-NotNull $containerGroupCreated.Volumes[0].AzureFile

src/ResourceManager/ContainerInstance/Commands.ContainerInstance.Test/SessionRecords/Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests/TestCreateContainerGroupWithVolume.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
"RequestUri": "/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/ps9107/providers/Microsoft.ContainerInstance/containerGroups/ps2492?api-version=2018-02-01-preview",
353353
"EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvYWU0M2IxZTMtYzM1ZC00YzhjLWJjMGQtZjE0OGI0YzUyYjc4L3Jlc291cmNlR3JvdXBzL3BzOTEwNy9wcm92aWRlcnMvTWljcm9zb2Z0LkNvbnRhaW5lckluc3RhbmNlL2NvbnRhaW5lckdyb3Vwcy9wczI0OTI/YXBpLXZlcnNpb249MjAxOC0wMi0wMS1wcmV2aWV3",
354354
"RequestMethod": "PUT",
355-
"RequestBody": "{\r\n \"properties\": {\r\n \"containers\": [\r\n {\r\n \"name\": \"ps2492\",\r\n \"properties\": {\r\n \"image\": \"alpine\",\r\n \"command\": [\r\n \"ls\",\r\n \"/mnt/azfile\"\r\n ],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n },\r\n \"volumeMounts\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"mountPath\": \"/mnt/azfile\"\r\n }\r\n ]\r\n }\r\n }\r\n ],\r\n \"restartPolicy\": \"Never\",\r\n \"osType\": \"Linux\",\r\n \"volumes\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"azureFile\": {\r\n \"shareName\": \"acipstestshare\",\r\n \"storageAccountName\": \"acipstest\",\r\n \"storageAccountKey\": \"ELFwG1AfwHJbr2kC0N/k8P+kz+t/UHoYMKtQnhr5B/M2sZ+65PqSyQP+aiY9A7j0VSa6e2ZId/3r2zOL+Cb8rw==\"\r\n }\r\n }\r\n ]\r\n },\r\n \"location\": \"westus\"\r\n}",
355+
"RequestBody": "{\r\n \"properties\": {\r\n \"containers\": [\r\n {\r\n \"name\": \"ps2492\",\r\n \"properties\": {\r\n \"image\": \"acc.azurecr.io/alpine\",\r\n \"command\": [\r\n \"ls\",\r\n \"/mnt/azfile\"\r\n ],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n },\r\n \"volumeMounts\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"mountPath\": \"/mnt/azfile\"\r\n }\r\n ]\r\n }\r\n }\r\n ],\r\n \"restartPolicy\": \"Never\",\r\n \"osType\": \"Linux\",\r\n \"imageRegistryCredentials\": [\r\n {\r\n \"server\": \"acc.azurecr.io\",\r\n \"username\": \"acc\",\r\n \"password\": \"password\",\r\n }\r\n ],\r\n \"volumes\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"azureFile\": {\r\n \"shareName\": \"acipstestshare\",\r\n \"storageAccountName\": \"acipstest\",\r\n \"storageAccountKey\": \"ELFwG1AfwHJbr2kC0N/k8P+kz+t/UHoYMKtQnhr5B/M2sZ+65PqSyQP+aiY9A7j0VSa6e2ZId/3r2zOL+Cb8rw==\"\r\n }\r\n }\r\n ]\r\n },\r\n \"location\": \"westus\"\r\n}",
356356
"RequestHeaders": {
357357
"Content-Type": [
358358
"application/json; charset=utf-8"
@@ -373,7 +373,7 @@
373373
"Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/0.0.0.0"
374374
]
375375
},
376-
"ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Creating\",\r\n \"containers\": [\r\n {\r\n \"name\": \"ps2492\",\r\n \"properties\": {\r\n \"image\": \"alpine\",\r\n \"command\": [\r\n \"ls\",\r\n \"/mnt/azfile\"\r\n ],\r\n \"ports\": [],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n },\r\n \"volumeMounts\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"mountPath\": \"/mnt/azfile\"\r\n }\r\n ]\r\n }\r\n }\r\n ],\r\n \"restartPolicy\": \"Never\",\r\n \"osType\": \"Linux\",\r\n \"volumes\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"azureFile\": {\r\n \"shareName\": \"acipstestshare\",\r\n \"storageAccountName\": \"acipstest\"\r\n }\r\n }\r\n ],\r\n \"instanceView\": {\r\n \"events\": [],\r\n \"state\": \"Pending\"\r\n }\r\n },\r\n \"id\": \"/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/ps9107/providers/Microsoft.ContainerInstance/containerGroups/ps2492\",\r\n \"name\": \"ps2492\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}",
376+
"ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Creating\",\r\n \"containers\": [\r\n {\r\n \"name\": \"ps2492\",\r\n \"properties\": {\r\n \"image\": \"acc.azurecr.io/alpine\",\r\n \"command\": [\r\n \"ls\",\r\n \"/mnt/azfile\"\r\n ],\r\n \"ports\": [],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n },\r\n \"volumeMounts\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"mountPath\": \"/mnt/azfile\"\r\n }\r\n ]\r\n }\r\n }\r\n ],\r\n \"restartPolicy\": \"Never\",\r\n \"osType\": \"Linux\",\r\n \"imageRegistryCredentials\": [\r\n {\r\n \"server\": \"acc.azurecr.io\",\r\n \"username\": \"acc\",\r\n \"password\": \"\",\r\n }\r\n ],\r\n \"volumes\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"azureFile\": {\r\n \"shareName\": \"acipstestshare\",\r\n \"storageAccountName\": \"acipstest\"\r\n }\r\n }\r\n ],\r\n \"instanceView\": {\r\n \"events\": [],\r\n \"state\": \"Pending\"\r\n }\r\n },\r\n \"id\": \"/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/ps9107/providers/Microsoft.ContainerInstance/containerGroups/ps2492\",\r\n \"name\": \"ps2492\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}",
377377
"ResponseHeaders": {
378378
"Content-Length": [
379379
"726"
@@ -436,7 +436,7 @@
436436
"Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/0.0.0.0"
437437
]
438438
},
439-
"ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Creating\",\r\n \"containers\": [\r\n {\r\n \"name\": \"ps2492\",\r\n \"properties\": {\r\n \"image\": \"alpine\",\r\n \"command\": [\r\n \"ls\",\r\n \"/mnt/azfile\"\r\n ],\r\n \"ports\": [],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n },\r\n \"volumeMounts\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"mountPath\": \"/mnt/azfile\"\r\n }\r\n ]\r\n }\r\n }\r\n ],\r\n \"restartPolicy\": \"Never\",\r\n \"osType\": \"Linux\",\r\n \"volumes\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"azureFile\": {\r\n \"shareName\": \"acipstestshare\",\r\n \"storageAccountName\": \"acipstest\"\r\n }\r\n }\r\n ],\r\n \"instanceView\": {\r\n \"events\": [],\r\n \"state\": \"Pending\"\r\n }\r\n },\r\n \"id\": \"/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/ps9107/providers/Microsoft.ContainerInstance/containerGroups/ps2492\",\r\n \"name\": \"ps2492\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}",
439+
"ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Creating\",\r\n \"containers\": [\r\n {\r\n \"name\": \"ps2492\",\r\n \"properties\": {\r\n \"image\": \"acc.azurecr.io/alpine\",\r\n \"command\": [\r\n \"ls\",\r\n \"/mnt/azfile\"\r\n ],\r\n \"ports\": [],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n },\r\n \"volumeMounts\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"mountPath\": \"/mnt/azfile\"\r\n }\r\n ]\r\n }\r\n }\r\n ],\r\n \"restartPolicy\": \"Never\",\r\n \"osType\": \"Linux\",\r\n \"imageRegistryCredentials\": [\r\n {\r\n \"server\": \"acc.azurecr.io\",\r\n \"username\": \"acc\",\r\n \"password\": \"\",\r\n }\r\n ],\r\n \"volumes\": [\r\n {\r\n \"name\": \"azurefile\",\r\n \"azureFile\": {\r\n \"shareName\": \"acipstestshare\",\r\n \"storageAccountName\": \"acipstest\"\r\n }\r\n }\r\n ],\r\n \"instanceView\": {\r\n \"events\": [],\r\n \"state\": \"Pending\"\r\n }\r\n },\r\n \"id\": \"/subscriptions/ae43b1e3-c35d-4c8c-bc0d-f148b4c52b78/resourceGroups/ps9107/providers/Microsoft.ContainerInstance/containerGroups/ps2492\",\r\n \"name\": \"ps2492\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}",
440440
"ResponseHeaders": {
441441
"Content-Length": [
442442
"726"

src/ResourceManager/ContainerInstance/Commands.ContainerInstance/Commands/NewAzureContainerGroupCommand.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ namespace Microsoft.Azure.Commands.ContainerInstance
3232
public class NewAzureContainerGroupCommand : ContainerInstanceCmdletBase
3333
{
3434
protected const string CreateContainerGroupBaseParamSet = "CreateContainerGroupBaseParamSet";
35-
protected const string CreateContainerGroupWithRegistryParamSet = "CreateContainerGroupWithRegistryParamSet";
3635
protected const string CreateContainerGroupWithAzureFileVolumeParamSet = "CreateContainerGroupWithAzureFileMountParamSet";
3736

3837
[Parameter(
@@ -60,8 +59,7 @@ public class NewAzureContainerGroupCommand : ContainerInstanceCmdletBase
6059
public string Image { get; set; }
6160

6261
[Parameter(
63-
Mandatory = true,
64-
ParameterSetName = CreateContainerGroupWithRegistryParamSet,
62+
Mandatory = false,
6563
HelpMessage = "The custom container registry credential.")]
6664
[ValidateNotNullOrEmpty]
6765
public PSCredential RegistryCredential { get; set; }
@@ -165,7 +163,6 @@ public class NewAzureContainerGroupCommand : ContainerInstanceCmdletBase
165163

166164
[Parameter(
167165
Mandatory = false,
168-
ParameterSetName = CreateContainerGroupWithRegistryParamSet,
169166
HelpMessage = "The custom container registry login server.")]
170167
[ValidateNotNullOrEmpty]
171168
[Alias("RegistryServer")]

src/ResourceManager/ContainerInstance/Commands.ContainerInstance/Models/ContainerGroupCreationParameters.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,12 @@ public class ContainerGroupCreationParameters
161161
/// </summary>
162162
public void Validate()
163163
{
164-
if (string.IsNullOrEmpty(this.Location))
165-
{
166-
throw new ArgumentException("Please specify Location");
167-
}
164+
ValidateRegistryParameters();
165+
ValidateAzureFileVolumeParameters();
166+
}
168167

168+
private void ValidateRegistryParameters()
169+
{
169170
if (!string.IsNullOrEmpty(this.RegistryServer))
170171
{
171172
if (string.IsNullOrEmpty(this.RegistryUsername) || string.IsNullOrEmpty(this.RegistryPassword))
@@ -189,7 +190,10 @@ public void Validate()
189190

190191
this.RegistryServer = acrServer;
191192
}
193+
}
192194

195+
private void ValidateAzureFileVolumeParameters()
196+
{
193197
if (!string.IsNullOrWhiteSpace(this.AzureFileVolumeMountPath) && this.AzureFileVolumeMountPath.Contains(":"))
194198
{
195199
throw new ArgumentException("Azure File volume mount path must not contain ':'");

src/ResourceManager/ContainerInstance/Commands.ContainerInstance/help/AzureRM.ContainerInstance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
---
1+
---
22
Module Name: AzureRM.ContainerInstance
33
Module Guid:
44
Download Help Link:

src/ResourceManager/ContainerInstance/Commands.ContainerInstance/help/New-AzureRmContainerGroup.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,8 @@ Creates a container group.
1414

1515
### CreateContainerGroupBaseParamSet (Default)
1616
```
17-
New-AzureRmContainerGroup [-ResourceGroupName] <String> [-Name] <String> [-Image] <String> [-Location <String>]
18-
[-OsType <String>] [-RestartPolicy <String>] [-Cpu <Int32>] [-MemoryInGB <Double>] [-IpAddressType <String>]
19-
[-DnsNameLabel <String>] [-Port <Int32[]>] [-Command <String>] [-EnvironmentVariable <Hashtable>]
20-
[-Tag <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
21-
```
22-
23-
### CreateContainerGroupWithRegistryParamSet
24-
```
2517
New-AzureRmContainerGroup [-ResourceGroupName] <String> [-Name] <String> [-Image] <String>
26-
-RegistryCredential <PSCredential> [-Location <String>] [-OsType <String>] [-RestartPolicy <String>]
18+
[-RegistryCredential <PSCredential>] [-Location <String>] [-OsType <String>] [-RestartPolicy <String>]
2719
[-Cpu <Int32>] [-MemoryInGB <Double>] [-IpAddressType <String>] [-DnsNameLabel <String>] [-Port <Int32[]>]
2820
[-Command <String>] [-EnvironmentVariable <Hashtable>] [-RegistryServerDomain <String>] [-Tag <Hashtable>]
2921
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
@@ -32,11 +24,12 @@ New-AzureRmContainerGroup [-ResourceGroupName] <String> [-Name] <String> [-Image
3224
### CreateContainerGroupWithAzureFileMountParamSet
3325
```
3426
New-AzureRmContainerGroup [-ResourceGroupName] <String> [-Name] <String> [-Image] <String>
35-
-AzureFileVolumeShareName <String> -AzureFileVolumeAccountCredential <PSCredential>
36-
-AzureFileVolumeMountPath <String> [-Location <String>] [-OsType <String>] [-RestartPolicy <String>]
37-
[-Cpu <Int32>] [-MemoryInGB <Double>] [-IpAddressType <String>] [-DnsNameLabel <String>] [-Port <Int32[]>]
38-
[-Command <String>] [-EnvironmentVariable <Hashtable>] [-Tag <Hashtable>]
39-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
27+
[-RegistryCredential <PSCredential>] -AzureFileVolumeShareName <String>
28+
-AzureFileVolumeAccountCredential <PSCredential> -AzureFileVolumeMountPath <String> [-Location <String>]
29+
[-OsType <String>] [-RestartPolicy <String>] [-Cpu <Int32>] [-MemoryInGB <Double>] [-IpAddressType <String>]
30+
[-DnsNameLabel <String>] [-Port <Int32[]>] [-Command <String>] [-EnvironmentVariable <Hashtable>]
31+
[-RegistryServerDomain <String>] [-Tag <Hashtable>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
32+
[-Confirm] [<CommonParameters>]
4033
```
4134

4235
## DESCRIPTION
@@ -432,10 +425,10 @@ The custom container registry credential.
432425
433426
```yaml
434427
Type: PSCredential
435-
Parameter Sets: CreateContainerGroupWithRegistryParamSet
428+
Parameter Sets: (All)
436429
Aliases:
437430

438-
Required: True
431+
Required: False
439432
Position: Named
440433
Default value: None
441434
Accept pipeline input: False
@@ -447,7 +440,7 @@ The custom container registry login server.
447440
448441
```yaml
449442
Type: String
450-
Parameter Sets: CreateContainerGroupWithRegistryParamSet
443+
Parameter Sets: (All)
451444
Aliases: RegistryServer
452445

453446
Required: False

0 commit comments

Comments
 (0)