Skip to content

Commit 18af39c

Browse files
committed
Merge branch 'preview' of https://github.com/Azure/azure-powershell into preview
2 parents 1847cb9 + 21dc0cc commit 18af39c

27 files changed

+9042
-11546
lines changed

src/ResourceManager/Compute/Stack/Commands.Compute/help/Get-AzureRmDisk.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
8282
8383
## OUTPUTS
8484
85-
### System.Object
85+
### Microsoft.Azure.Commands.Compute.Automation.Models.PSDiskList
8686
8787
## NOTES
8888

src/ResourceManager/ContainerInstance/ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Apply Azure Container Instance SDK 2017-10-01
22+
- Support container run-to-completion
23+
- Support Azure File volume mount
24+
- Support opening multiple ports for public IP
2125

2226
## Version 0.1.0
2327
* Add support for online help

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

Lines changed: 6 additions & 3 deletions
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.0-preview\lib\net452\Microsoft.Azure.Management.ContainerInstance.dll</HintPath>
50+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerInstance.1.0.1-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">
@@ -187,10 +187,13 @@
187187
<None Include="ScenarioTests\ContainerInstanceTests.ps1">
188188
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
189189
</None>
190-
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\TestContainerGroupCommands.json">
190+
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\TestContainerInstanceLog.json">
191191
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
192192
</None>
193-
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\TestContainerInstanceLog.json">
193+
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\TestCreateContainerGroup.json">
194+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
195+
</None>
196+
<None Include="SessionRecords\Microsoft.Azure.Commands.ContainerInstance.Test.ScenarioTests.ContainerInstanceTests\TestCreateContainerGroupWithVolume.json">
194197
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
195198
</None>
196199
</ItemGroup>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public ContainerInstanceTests(ITestOutputHelper output)
3131

3232
[Fact]
3333
[Trait(Category.AcceptanceType, Category.CheckIn)]
34-
public void TestContainerGroupCommands()
34+
public void TestCreateContainerGroup()
3535
{
3636
TestController.NewInstance.RunPowerShellTest("Test-AzureRmContainerGroup");
3737
}
@@ -42,5 +42,12 @@ public void TestContainerInstanceLog()
4242
{
4343
TestController.NewInstance.RunPowerShellTest("Test-AzureRmContainerInstanceLog");
4444
}
45+
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
public void TestCreateContainerGroupWithVolume()
49+
{
50+
TestController.NewInstance.RunPowerShellTest("Test-AzureRmContainerGroupWithVolumeMount");
51+
}
4552
}
4653
}

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

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,22 @@ function Test-AzureRmContainerGroup
2323
$location = Get-ProviderLocation "Microsoft.ContainerInstance/ContainerGroups"
2424
$image = "nginx"
2525
$osType = "Linux"
26+
$restartPolicy = "Never"
27+
$port1 = 8000
28+
$port2 = 8001
2629

2730
try
2831
{
2932
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location
30-
$containerGroupCreated = New-AzureRmContainerGroup -ResourceGroupName $resourceGroupName -Name $containerGroupName -Image $image -OsType $osType -IpAddressType "public" -Cpu 1 -Memory 1.5
33+
$containerGroupCreated = New-AzureRmContainerGroup -ResourceGroupName $resourceGroupName -Name $containerGroupName -Image $image -OsType $osType -RestartPolicy $restartPolicy -IpAddressType "public" -Port @($port1, $port2) -Cpu 1 -Memory 1.5
3134

3235
Assert-AreEqual $containerGroupCreated.ResourceGroupName $resourceGroupName
3336
Assert-AreEqual $containerGroupCreated.Name $containerGroupName
3437
Assert-AreEqual $containerGroupCreated.Location $location
3538
Assert-AreEqual $containerGroupCreated.OsType $osType
39+
Assert-AreEqual $containerGroupCreated.RestartPolicy $restartPolicy
3640
Assert-NotNull $containerGroupCreated.IpAddress
41+
Assert-AreEqual $containerGroupCreated.Ports.Count 2
3742
Assert-NotNull $containerGroupCreated.Containers
3843
Assert-AreEqual $containerGroupCreated.Containers[0].Image $image
3944
Assert-AreEqual $containerGroupCreated.Containers[0].Cpu 1
@@ -64,13 +69,13 @@ function Test-AzureRmContainerInstanceLog
6469
$resourceGroupName = Get-RandomResourceGroupName
6570
$containerGroupName = Get-RandomContainerGroupName
6671
$location = Get-ProviderLocation "Microsoft.ContainerInstance/ContainerGroups"
67-
$image = "nginx"
72+
$image = "alpine"
6873
$osType = "Linux"
6974

7075
try
7176
{
7277
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location
73-
$containerGroupCreated = New-AzureRmContainerGroup -ResourceGroupName $resourceGroupName -Name $containerGroupName -Image $image -OsType $osType -IpAddressType "public"
78+
$containerGroupCreated = New-AzureRmContainerGroup -ResourceGroupName $resourceGroupName -Name $containerGroupName -Image $image -OsType $osType -IpAddressType "Public" -RestartPolicy "Never" -Command "echo hello"
7479
$containerInstanceName = $containerGroupName
7580

7681
$log = $containerGroupCreated | Get-AzureRmContainerInstanceLog -Name $containerInstanceName
@@ -85,6 +90,44 @@ function Test-AzureRmContainerInstanceLog
8590
}
8691
}
8792

93+
<#
94+
.SYNOPSIS
95+
Test New-AzureRmContainerGroup with Azure File volume mount.
96+
#>
97+
function Test-AzureRmContainerGroupWithVolumeMount
98+
{
99+
$resourceGroupName = Get-RandomResourceGroupName
100+
$containerGroupName = Get-RandomContainerGroupName
101+
$location = Get-ProviderLocation "Microsoft.ContainerInstance/ContainerGroups"
102+
$image = "alpine"
103+
$shareName = "acipstestshare"
104+
$accountName = "acipstest"
105+
$accountKey = "password"
106+
$secureAccountKey = ConvertTo-SecureString $accountKey -AsPlainText -Force
107+
$accountCredential = New-Object System.Management.Automation.PSCredential ($accountName, $secureAccountKey)
108+
$mountPath = "/mnt/azfile"
109+
110+
try
111+
{
112+
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
114+
115+
Assert-NotNull $containerGroupCreated.Volumes
116+
Assert-NotNull $containerGroupCreated.Volumes[0].AzureFile
117+
Assert-AreEqual $containerGroupCreated.Volumes[0].AzureFile.ShareName $shareName
118+
Assert-AreEqual $containerGroupCreated.Volumes[0].AzureFile.StorageAccountName $accountName
119+
Assert-NotNull $containerGroupCreated.Containers[0].VolumeMounts
120+
Assert-AreEqual $containerGroupCreated.Containers[0].VolumeMounts[0].MountPath $mountPath
121+
122+
Remove-AzureRmContainerGroup -ResourceGroupName $resourceGroupName -Name $containerGroupName
123+
}
124+
finally
125+
{
126+
# Cleanup
127+
Clean-ResourceGroup $resourceGroupName
128+
}
129+
}
130+
88131
<#
89132
.SYNOPSIS
90133
Assert a container group object.
@@ -109,7 +152,9 @@ function Assert-ContainerGroup
109152
Assert-AreEqual $Actual.Name $Expected.Name
110153
Assert-AreEqual $Actual.Location $Expected.Location
111154
Assert-AreEqual $Actual.OsType $Expected.OsType
155+
Assert-AreEqual $Actual.RestartPolicy $Expected.RestartPolicy
112156
Assert-NotNull $Actual.IpAddress
157+
Assert-AreEqual $Actual.Ports.Count $Expected.Ports.Count
113158
Assert-NotNull $Actual.Containers
114159
Assert-AreEqual $Actual.Containers[0].Image $Expected.Containers[0].Image
115160
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: 3716 additions & 4352 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: 778 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 4142 additions & 7112 deletions
Large diffs are not rendered by default.

src/ResourceManager/ContainerInstance/Commands.ContainerInstance.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package id="Hyak.Common" version="1.0.3" targetFramework="net45" />
44
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
55
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
6-
<package id="Microsoft.Azure.Management.ContainerInstance" version="1.0.0-preview" targetFramework="net452" />
6+
<package id="Microsoft.Azure.Management.ContainerInstance" version="1.0.1-preview" targetFramework="net452" />
77
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
88
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
99
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net45" />

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<Compile Include="Commands\ContainerInstanceCmdletBase.cs" />
5757
<Compile Include="Models\ContainerInstanceAutoMapperProfile.cs" />
5858
<Compile Include="Models\PSContainer.cs" />
59-
<Compile Include="Models\PSContainerEvent.cs" />
59+
<Compile Include="Models\PSEvent.cs" />
6060
<Compile Include="Models\PSContainerGroup.cs" />
6161
<Compile Include="Models\PSContainerGroupList.cs" />
6262
<Compile Include="Models\PSContainerState.cs" />
@@ -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.0-preview\lib\net452\Microsoft.Azure.Management.ContainerInstance.dll</HintPath>
68+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerInstance.1.0.1-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: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public abstract class ContainerInstanceCmdletBase : AzureRMCmdlet
4242
/// </summary>
4343
protected const string ContainerInstanceLogNoun = "AzureRmContainerInstanceLog";
4444

45+
/// <summary>
46+
/// Azure File volume name.
47+
/// </summary>
48+
private const string AzureFileVolumeName = "azurefile";
49+
4550
/// <summary>
4651
/// Container instance management client.
4752
/// </summary>
@@ -117,18 +122,31 @@ public ContainerGroup CreateContainerGroup(ContainerGroupCreationParameters para
117122
EnvironmentVariables = parameters.EnvironmentVariables?.Select(e => new EnvironmentVariable(e.Key, e.Value)).ToList()
118123
};
119124

125+
if (!string.IsNullOrEmpty(parameters.AzureFileVolumeMountPath))
126+
{
127+
container.VolumeMounts = new List<VolumeMount>
128+
{
129+
new VolumeMount
130+
{
131+
Name = ContainerInstanceCmdletBase.AzureFileVolumeName,
132+
MountPath = parameters.AzureFileVolumeMountPath
133+
}
134+
};
135+
}
136+
120137
var containerGroup = new ContainerGroup()
121138
{
122139
Location = parameters.Location,
123140
Tags = parameters.Tags,
124141
Containers = new List<Container>() { container },
125-
OsType = parameters.OsType
142+
OsType = parameters.OsType,
143+
RestartPolicy = parameters.RestartPolicy
126144
};
127145

128146
if (string.Equals(IpAddress.Type, parameters.IpAddressType, StringComparison.OrdinalIgnoreCase))
129147
{
130-
container.Ports = new List<ContainerPort>() { new ContainerPort(parameters.Port) };
131-
containerGroup.IpAddress = new IpAddress(new List<Port>() { new Port(parameters.Port) });
148+
container.Ports = parameters.Ports.Select(p => new ContainerPort(p)).ToList();
149+
containerGroup.IpAddress = new IpAddress(parameters.Ports.Select(p => new Port(p)).ToList());
132150
}
133151

134152
if (!string.IsNullOrEmpty(parameters.RegistryServer))
@@ -144,6 +162,25 @@ public ContainerGroup CreateContainerGroup(ContainerGroupCreationParameters para
144162
};
145163
}
146164

165+
if (!string.IsNullOrEmpty(parameters.AzureFileVolumeMountPath))
166+
{
167+
var azureFileVolume = new AzureFileVolume
168+
{
169+
ShareName = parameters.AzureFileVolumeShareName,
170+
StorageAccountName = parameters.AzureFileVolumeAccountName,
171+
StorageAccountKey = parameters.AzureFileVolumeAccountKey
172+
};
173+
174+
containerGroup.Volumes = new List<Volume>
175+
{
176+
new Volume
177+
{
178+
Name = ContainerInstanceCmdletBase.AzureFileVolumeName,
179+
AzureFile = azureFileVolume
180+
}
181+
};
182+
}
183+
147184
return this.ContainerClient.ContainerGroups.CreateOrUpdate(
148185
resourceGroupName: parameters.ResourceGroupName,
149186
containerGroupName: parameters.Name,

0 commit comments

Comments
 (0)