Skip to content

Commit e09abe0

Browse files
authored
Merge pull request #5477 from xizhamsft/preview
add dns name label support for container instance
2 parents c1c236f + 2a82899 commit e09abe0

18 files changed

+1261
-41151
lines changed

src/ResourceManager/ContainerInstance/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Apply Azure Container Instance SDK 2018-02-01
22+
- Support DNS name label
2123

2224
## Version 0.2.2
2325
* Added Location Completer to -Location parameters allowing tab completion through valid Locations

src/ResourceManager/ContainerInstance/Commands.ContainerInstance.Test/Commands.ContainerInstance.Test.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<HintPath>..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll</HintPath>
4848
</Reference>
4949
<Reference Include="Microsoft.Azure.Management.ContainerInstance, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
50-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerInstance.1.0.1-preview\lib\net452\Microsoft.Azure.Management.ContainerInstance.dll</HintPath>
50+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerInstance.1.0.2-preview\lib\net452\Microsoft.Azure.Management.ContainerInstance.dll</HintPath>
5151
<Private>True</Private>
5252
</Reference>
5353
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -193,6 +193,9 @@
193193
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\TestCreateContainerGroup.json">
194194
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
195195
</None>
196+
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\TestCreateContainerGroupWithDnsNameLabel.json" >
197+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
198+
</None>
196199
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\TestCreateContainerGroupWithVolume.json">
197200
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
198201
</None>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,12 @@ public void TestCreateContainerGroupWithVolume()
4949
{
5050
TestController.NewInstance.RunPowerShellTest("Test-AzureRmContainerGroupWithVolumeMount");
5151
}
52+
53+
[Fact]
54+
[Trait(Category.AcceptanceType, Category.CheckIn)]
55+
public void TestCreateContainerGroupWithDnsNameLabel()
56+
{
57+
TestController.NewInstance.RunPowerShellTest("Test-AzureRmContainerGroupWithDnsNameLabel");
58+
}
5259
}
5360
}

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,57 @@ function Test-AzureRmContainerGroupWithVolumeMount
128128
}
129129
}
130130

131+
<#
132+
.SYNOPSIS
133+
Test New-AzureRmContainerGroup with DNS name label.
134+
#>
135+
function Test-AzureRmContainerGroupWithDnsNameLabel
136+
{
137+
$resourceGroupName = Get-RandomResourceGroupName
138+
$containerGroupName = Get-RandomContainerGroupName
139+
$fqdn = $containerGroupName + ".westus.azurecontainer.io"
140+
$location = Get-ProviderLocation "Microsoft.ContainerInstance/ContainerGroups"
141+
$image = "nginx"
142+
$osType = "Linux"
143+
$restartPolicy = "Never"
144+
$port1 = 8000
145+
$port2 = 8001
146+
147+
try
148+
{
149+
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location
150+
$containerGroupCreated = New-AzureRmContainerGroup -ResourceGroupName $resourceGroupName -Name $containerGroupName -Image $image -OsType $osType -RestartPolicy $restartPolicy -DnsNameLabel $containerGroupName -Port @($port1, $port2) -Cpu 1 -Memory 1.5
151+
152+
Assert-AreEqual $containerGroupCreated.ResourceGroupName $resourceGroupName
153+
Assert-AreEqual $containerGroupCreated.Name $containerGroupName
154+
Assert-AreEqual $containerGroupCreated.Location $location
155+
Assert-AreEqual $containerGroupCreated.OsType $osType
156+
Assert-AreEqual $containerGroupCreated.RestartPolicy $restartPolicy
157+
Assert-NotNull $containerGroupCreated.IpAddress
158+
Assert-AreEqual $containerGroupCreated.DnsNameLabel $containerGroupName
159+
Assert-AreEqual $containerGroupCreated.Fqdn $fqdn
160+
Assert-AreEqual $containerGroupCreated.Ports.Count 2
161+
Assert-NotNull $containerGroupCreated.Containers
162+
Assert-AreEqual $containerGroupCreated.Containers[0].Image $image
163+
Assert-AreEqual $containerGroupCreated.Containers[0].Cpu 1
164+
Assert-AreEqual $containerGroupCreated.Containers[0].MemoryInGb 1.5
165+
166+
$retrievedContainerGroup = Get-AzureRmContainerGroup -ResourceGroupName $resourceGroupName -Name $containerGroupName
167+
Assert-ContainerGroup $containerGroupCreated $retrievedContainerGroup
168+
169+
$retrievedContainerGroupList = Get-AzureRmContainerGroup -ResourceGroupName $resourceGroupName
170+
Assert-AreEqual $retrievedContainerGroupList.Count 1
171+
Assert-ContainerGroup $containerGroupCreated $retrievedContainerGroupList[0]
172+
173+
$retrievedContainerGroup | Remove-AzureRmContainerGroup
174+
}
175+
finally
176+
{
177+
# Cleanup
178+
Clean-ResourceGroup $resourceGroupName
179+
}
180+
}
181+
131182
<#
132183
.SYNOPSIS
133184
Assert a container group object.
@@ -155,6 +206,7 @@ function Assert-ContainerGroup
155206
Assert-AreEqual $Actual.RestartPolicy $Expected.RestartPolicy
156207
Assert-NotNull $Actual.IpAddress
157208
Assert-AreEqual $Actual.Ports.Count $Expected.Ports.Count
209+
Assert-AreEqual $Actual.DnsNameLabel $Expected.DnsNameLabel
158210
Assert-NotNull $Actual.Containers
159211
Assert-AreEqual $Actual.Containers[0].Image $Expected.Containers[0].Image
160212
Assert-AreEqual $Actual.Containers[0].Cpu $Expected.Containers[0].Cpu

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

Lines changed: 110 additions & 19388 deletions
Large diffs are not rendered by default.

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

Lines changed: 124 additions & 124 deletions
Large diffs are not rendered by default.

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

Lines changed: 778 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 100 additions & 21592 deletions
Large diffs are not rendered by default.

src/ResourceManager/ContainerInstance/Commands.ContainerInstance/Commands.ContainerInstance.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
</ItemGroup>
6666
<ItemGroup>
6767
<Reference Include="Microsoft.Azure.Management.ContainerInstance, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
68-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerInstance.1.0.1-preview\lib\net452\Microsoft.Azure.Management.ContainerInstance.dll</HintPath>
68+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerInstance.1.0.2-preview\lib\net452\Microsoft.Azure.Management.ContainerInstance.dll</HintPath>
6969
</Reference>
7070
</ItemGroup>
7171
<ItemGroup>

src/ResourceManager/ContainerInstance/Commands.ContainerInstance/Commands/ContainerInstanceCmdletBase.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,13 @@ public ContainerGroup CreateContainerGroup(ContainerGroupCreationParameters para
143143
RestartPolicy = parameters.RestartPolicy
144144
};
145145

146-
if (string.Equals(IpAddress.Type, parameters.IpAddressType, StringComparison.OrdinalIgnoreCase))
146+
if (string.Equals(IpAddress.Type, parameters.IpAddressType, StringComparison.OrdinalIgnoreCase) ||
147+
!string.IsNullOrEmpty(parameters.DnsNameLabel))
147148
{
148149
container.Ports = parameters.Ports.Select(p => new ContainerPort(p)).ToList();
149-
containerGroup.IpAddress = new IpAddress(parameters.Ports.Select(p => new Port(p)).ToList());
150+
containerGroup.IpAddress = new IpAddress(
151+
ports: parameters.Ports.Select(p => new Port(p)).ToList(),
152+
dnsNameLabel: parameters.DnsNameLabel);
150153
}
151154

152155
if (!string.IsNullOrEmpty(parameters.RegistryServer))

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ public class NewAzureContainerGroupCommand : ContainerInstanceCmdletBase
139139
IgnoreCase = true)]
140140
public string IpAddressType { get; set; }
141141

142+
[Parameter(
143+
Mandatory = false,
144+
HelpMessage = "The DNS name label for the IP address.")]
145+
[ValidateNotNullOrEmpty]
146+
public string DnsNameLabel { get; set; }
147+
142148
[Parameter(
143149
Mandatory = false,
144150
HelpMessage = "The port(s) to open. Default: [80]")]
@@ -183,6 +189,7 @@ public override void ExecuteCmdlet()
183189
OsType = this.OsType ?? ContainerGroupCreationParameters.DefaultOsType,
184190
RestartPolicy = this.RestartPolicy ?? ContainerGroupRestartPolicy.Always,
185191
IpAddressType = this.IpAddressType,
192+
DnsNameLabel = this.DnsNameLabel,
186193
Ports = this.Port ?? ContainerGroupCreationParameters.DefaultPorts,
187194
ContainerImage = this.Image,
188195
EnvironmentVariables = this.ConvertHashtableToDictionary(this.EnvironmentVariable),

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public class ContainerGroupCreationParameters
8686
/// </summary>
8787
public string IpAddressType { get; set; }
8888

89+
/// <summary>
90+
/// Gets or sets the DNS name label.
91+
/// </summary>
92+
public string DnsNameLabel { get; set; }
93+
8994
/// <summary>
9095
/// Gets or sets the ports.
9196
/// </summary>

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ public string ResourceGroupName
8989
/// </summary>
9090
public string IpAddress { get; set; }
9191

92+
/// <summary>
93+
/// Gets or sets the DNS name label.
94+
/// </summary>
95+
public string DnsNameLabel { get; set; }
96+
97+
/// <summary>
98+
/// Gets the FQDN.
99+
/// </summary>
100+
public string Fqdn { get; set; }
101+
92102
/// <summary>
93103
/// Gets or sets the ports.
94104
/// </summary>
@@ -131,6 +141,8 @@ public static PSContainerGroup FromContainerGroup(ContainerGroup containerGroup)
131141
ImageRegistryCredentials = containerGroup?.ImageRegistryCredentials,
132142
RestartPolicy = containerGroup?.RestartPolicy,
133143
IpAddress = containerGroup?.IpAddress?.Ip,
144+
DnsNameLabel = containerGroup?.IpAddress?.DnsNameLabel,
145+
Fqdn = containerGroup?.IpAddress?.Fqdn,
134146
Ports = containerGroup?.IpAddress?.Ports?.Select(p => ContainerInstanceAutoMapperProfile.Mapper.Map<PSPort>(p)).ToList(),
135147
OsType = containerGroup?.OsType,
136148
Volumes = containerGroup?.Volumes,

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ The container group Name.
129129
```yaml
130130
Type: String
131131
Parameter Sets: GetContainerGroupInResourceGroupParamSet
132-
Aliases:
132+
Aliases:
133133

134134
Required: True
135135
Position: 1
@@ -144,7 +144,7 @@ The resource Group Name.
144144
```yaml
145145
Type: String
146146
Parameter Sets: ListContainerGroupParamSet
147-
Aliases:
147+
Aliases:
148148

149149
Required: False
150150
Position: 0
@@ -156,7 +156,7 @@ Accept wildcard characters: False
156156
```yaml
157157
Type: String
158158
Parameter Sets: GetContainerGroupInResourceGroupParamSet
159-
Aliases:
159+
Aliases:
160160

161161
Required: True
162162
Position: 0
@@ -171,7 +171,7 @@ The resource id.
171171
```yaml
172172
Type: String
173173
Parameter Sets: GetContainerGroupByResourceIdParamSet
174-
Aliases:
174+
Aliases:
175175

176176
Required: True
177177
Position: Named
@@ -194,4 +194,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
194194
## NOTES
195195
196196
## RELATED LINKS
197-

src/ResourceManager/ContainerInstance/Commands.ContainerInstance/help/Get-AzureRmContainerInstanceLog.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ The container group name.
8989
```yaml
9090
Type: String
9191
Parameter Sets: GetContainerInstanceLogByNamesParamSet
92-
Aliases:
92+
Aliases:
9393

9494
Required: True
9595
Position: Named
@@ -119,7 +119,7 @@ The input container group object.
119119
```yaml
120120
Type: PSContainerGroup
121121
Parameter Sets: GetContainerInstanceLogByPSContainerGroupParamSet
122-
Aliases:
122+
Aliases:
123123

124124
Required: True
125125
Position: Named
@@ -135,7 +135,7 @@ Default: the same as the container group name
135135
```yaml
136136
Type: String
137137
Parameter Sets: (All)
138-
Aliases:
138+
Aliases:
139139

140140
Required: False
141141
Position: Named
@@ -150,7 +150,7 @@ The resource group name.
150150
```yaml
151151
Type: String
152152
Parameter Sets: GetContainerInstanceLogByNamesParamSet
153-
Aliases:
153+
Aliases:
154154

155155
Required: True
156156
Position: 0
@@ -165,7 +165,7 @@ The resource id.
165165
```yaml
166166
Type: String
167167
Parameter Sets: GetContainerInstanceLogByResourceIdParamSet
168-
Aliases:
168+
Aliases:
169169

170170
Required: True
171171
Position: Named
@@ -181,7 +181,7 @@ If not specify, the cmdlet will return up to 4MB tailed log
181181
```yaml
182182
Type: Int32
183183
Parameter Sets: (All)
184-
Aliases:
184+
Aliases:
185185

186186
Required: False
187187
Position: Named
@@ -204,4 +204,3 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
204204
## NOTES
205205
206206
## RELATED LINKS
207-

0 commit comments

Comments
 (0)