Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c39e44e
Merge branch 'dev' of https://github.com/Azure/azure-powershell into de
hyonholee Oct 28, 2015
570c4ca
Check fullSetParametersFile for null before attempting a Path.Combine
Mar 9, 2016
2049f0d
revert unintentional changes
Mar 9, 2016
ac1932c
Merge branch 'dev' of https://github.com/hyonholee/azure-powershell i…
hyonholee Mar 15, 2016
7b4f1ca
Update Compute client library to 12.0.0-prelease
hyonholee Mar 16, 2016
8a59316
Merge branch 'de' of https://github.com/hyonholee/azure-powershell in…
hyonholee Mar 16, 2016
6af0ac7
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
hyonholee Mar 19, 2016
aecab47
Fix LicenseType issue when piping to New-AzureRmVM.
hyonholee Mar 21, 2016
8307e2f
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
hyonholee Mar 21, 2016
4166301
Creating branch off hylee's dev branch and incorporating changes for …
moisesac Mar 22, 2016
7cf05cc
Updating help file for Disable encryption cmdlet
moisesac Mar 22, 2016
74fb716
Initialize hashtable after declaration to fix build break
Mar 22, 2016
4ef648a
detabify
Mar 22, 2016
33cf1b9
Add Export-AzureRmResourceGroupTemplate cmdlet
vivsriaus Mar 22, 2016
3e5967e
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
vivsriaus Mar 22, 2016
2a880dd
Merge pull request #2 from moisesac/mocardev
hyonholee Mar 22, 2016
053f2af
Change to Export-AzureRmResourceGroup
vivsriaus Mar 22, 2016
109f0d4
Fix build issue
vivsriaus Mar 22, 2016
9f0885a
Add more description to help
vivsriaus Mar 22, 2016
2b18858
Fix forceRerun parameter to accept any string.
hyonholee Mar 23, 2016
ede83f6
Add "EA" value for permission parameter of Set-AzurePlatformVMImage c…
hyonholee Mar 23, 2016
7dbf8b0
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
hyonholee Mar 23, 2016
db9ac37
Updating AzureDiskEncryption extension name and version for Production
moisesac Mar 23, 2016
2399ff7
Merge pull request #3 from moisesac/mocardev
hyonholee Mar 23, 2016
239041d
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
vivsriaus Mar 23, 2016
e997d06
Add format for DeploymentOperation
vivsriaus Mar 23, 2016
a3e632f
Add formats and types to psd1
vivsriaus Mar 23, 2016
53dc417
Update the default version for BGInfo and VMAccess extension to "2.*"
hyonholee Mar 23, 2016
6df2bce
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
hyonholee Mar 23, 2016
e583066
[Insights] Fix null object exception in powershell
vcanaa Mar 23, 2016
8c15b9c
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
gucalder Mar 23, 2016
7609092
Fixed Storage folder location for Release PS Script
Mar 23, 2016
82927c6
Fixes for Azure CDN PowerShell
Mar 23, 2016
0bc288c
CDN PowerShell, using link for AzureRM.Cdn.psd1
Mar 23, 2016
db8d015
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
vivsriaus Mar 23, 2016
ef5a076
Merge pull request #1995 from kuangweizhang/dev
Mar 23, 2016
4cbce53
Fixing disable encryption operation when VolumeType is Data
moisesac Mar 23, 2016
79668bd
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
vivsriaus Mar 23, 2016
bade235
Add test for export resource group
vivsriaus Mar 23, 2016
893887b
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
hyonholee Mar 23, 2016
ab27ef2
Merge pull request #4 from moisesac/mocardev
hyonholee Mar 23, 2016
cb353dc
Revert to old test framework version
vivsriaus Mar 23, 2016
ed4a2d8
update network powershell to new api version
deepakswifty Mar 23, 2016
1c47402
Merge pull request #1992 from hovsepm/dev
markcowl Mar 23, 2016
547e0d3
Merge pull request #5 from DeepakRajendranMsft/UpdateNetworkAndCompute
hyonholee Mar 23, 2016
b9ac919
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
vivsriaus Mar 23, 2016
f94872e
Updating help content to fix issues reported on github
ravbhatnagar Mar 23, 2016
88fcf88
Change apiVersion logic for policy. Use the override ApiVersion value…
vivsriaus Mar 23, 2016
2373c05
update change log for SAS token bug fix.
EmmaZhu Mar 24, 2016
96d4169
Update change log indent.
EmmaZhu Mar 24, 2016
e5467f3
Merge branch 'dev' of https://github.com/azure/azure-powershell into dev
ravbhatnagar Mar 24, 2016
20255cb
Merge pull request #1996 from AuxMon/dev
Mar 24, 2016
0029e68
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
vivsriaus Mar 24, 2016
a607189
Merge pull request #2000 from ravbhatnagar/dev
Mar 24, 2016
b0561fc
Merge pull request #2001 from wastoresh/dev
Mar 24, 2016
d1c76ec
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
vivsriaus Mar 24, 2016
79225db
Repairing help text XML
matt1883 Mar 24, 2016
e044f73
Add the wix file. Thanks Hovsep!
vivsriaus Mar 24, 2016
4388602
Merge pull request #1986 from hyonholee/dev
Mar 24, 2016
0815c28
Merge pull request #1917 from eocrawford/users/ethancr/bugfixes
markcowl Mar 24, 2016
2426c52
Merge pull request #1983 from vivsriaus/CaptureRG
markcowl Mar 24, 2016
380d900
Merge pull request #2002 from matt1883/dev
markcowl Mar 24, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
##2016.03.03 version 1.2.2
##2016.03.30 version 1.2.3
* Azure Storage
* Made Protocol parameter in following cmdlets to be nullable and optional
- New-AzureStorageBlobSASToken
- New-AzureStorageContainerSASToken
- New-AzureStorageFileSASToken
- New-AzureStorageShareSASToken
- New-AzureStorageQueueSASToken
- New-AzureStorageTableSASToken
- New-AzureStorageAccountSASToken

##2016.03.03 version 1.2.2
* Azure Compute (ARM):
* Add -LicenseType parameter to New-AzureRmVM for bring your own license (BYOL)
* Add -SecureExecution parameter to Set-AzureRmVMCustomScriptExtension
Expand Down
86 changes: 83 additions & 3 deletions setup/azurecmdfiles.wxi

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void RunPsTestWorkflow(
"ScenarioTests\\" + callingClassName + ".ps1",
_helper.RMProfileModule,
_helper.RMResourceModule,
@"AzureRm.Cdn.psd1");
@"AzureRM.Cdn.psd1");

try
{
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion src/ResourceManager/Cdn/Commands.Cdn/Commands.Cdn.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="AzureRm.Cdn.psd1">
<None Include="..\AzureRM.Cdn.psd1">
<Link>AzureRM.Cdn.psd1</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Microsoft.Azure.Commands.Cdn.dll-help.psd1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Compute, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.11.3.0-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.12.0.1-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.3.0-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.4.1.0-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -923,15 +923,15 @@ function Test-AzureDiskEncryptionExtension
{
# This test should be run in Live mode only not in Playback mode
#Pre-requisites to be filled in before running this test. The AAD app should belong to the directory as the user running the test.
$aadClientID = "";
$aadClientSecret = "";
#Fill in VM admin user and password
$adminUser = "";
$adminPassword = "";

$aadAppName = "detestaadapp";

#Resource group variables
$rgName = "detestrg";
$loc = "South Central US";
$rgName = Get-ComputeTestResourceName;
$loc = Get-ComputeVMLocation;

#Fill in VM admin user and password
$adminUser = "Foo12";
$adminPassword = "BaR@123" + $rgName;

#KeyVault config variables
$vaultName = "detestvault";
Expand All @@ -951,30 +951,54 @@ function Test-AzureDiskEncryptionExtension
$osDiskName = 'osdisk' + $vmName;
$dataDiskName = 'datadisk' + $vmName;
$osDiskCaching = 'ReadWrite';
$extraDataDiskName1 = $dataDiskName + '1';
$extraDataDiskName2 = $dataDiskName + '2';

#Network config variables
$vnetName = "detestvnet";
$subnetName = "detestsubnet";
$publicIpName = 'pubip' + $vmName;
$nicName = 'nic' + $vmName;



#Disk encryption variables
$keyEncryptionAlgorithm = "RSA-OAEP";
$volumeType = "All";

try
{
Login-AzureRmAccount;
# Create new resource group
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
# Create new resource group
New-AzureRmResourceGroup -Name $rgName -Location $loc -Force;

#Check if AAD app was already created
$SvcPrincipals = (Get-AzureRmADServicePrincipal -SearchString $aadAppName);
if(-not $SvcPrincipals)
{
# Create a new AD application if not created before
$identifierUri = [string]::Format("http://localhost:8080/{0}", $rgname);
$defaultHomePage = 'http://contoso.com';
$now = [System.DateTime]::Now;
$oneYearFromNow = $now.AddYears(1);
$aadClientSecret = Get-ResourceName;
$ADApp = New-AzureRmADApplication -DisplayName $aadAppName -HomePage $defaultHomePage -IdentifierUris $identifierUri -StartDate $now -EndDate $oneYearFromNow -Password $aadClientSecret;
Assert-NotNull $ADApp;
$servicePrincipal = New-AzureRmADServicePrincipal -ApplicationId $ADApp.ApplicationId;
$SvcPrincipals = (Get-AzureRmADServicePrincipal -SearchString $aadAppName);
# Was AAD app created?
Assert-NotNull $SvcPrincipals;
$aadClientID = $servicePrincipal.ApplicationId;
}
else
{
# Was AAD app already created?
Assert-NotNull $aadClientSecret;
$aadClientID = $SvcPrincipals[0].ApplicationId;
}

# Create new KeyVault
$keyVault = New-AzureRmKeyVault -VaultName $vaultName -ResourceGroupName $rgname -Location $loc -Sku standard;
$keyVault = Get-AzureRmKeyVault -VaultName $vaultName -ResourceGroupName $rgname
#set enabledForDiskEncryption
Write-Host 'Press go to https://resources.azure.com and set enabledForDiskEncryption flag on KeyVault. [ENTER] to continue or [CTRL-C] to abort...'
Read-Host
Set-AzureRmKeyVaultAccessPolicy -VaultName $vaultName -ResourceGroupName $rgname -EnabledForDiskEncryption;
#set permissions to AAD app to write secrets and keys
Set-AzureRmKeyVaultAccessPolicy -VaultName $vaultName -ServicePrincipalName $aadClientID -PermissionsToKeys all -PermissionsToSecrets all
#create a key in KeyVault to use as Kek
Expand Down Expand Up @@ -1019,17 +1043,69 @@ function Test-AzureDiskEncryptionExtension

$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred -ProvisionVMAgent;
$p = Set-AzureRmVMSourceImage -VM $p -PublisherName $imagePublisher -Offer $imageOffer -Skus $imageSku -Version "latest";



# Virtual Machine
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;

#Enable encryption on the VM
Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName -AadClientID $aadClientID -AadClientSecret $aadClientSecret -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $keyVaultResourceId -KeyEncryptionKeyUrl $keyEncryptionKeyUrl -KeyEncryptionKeyVaultId $keyVaultResourceId -Force;
#Get encryption status
$encryptionStatus = Get-AzureRmVmDiskEncryptionStatus -ResourceGroupName $rgname -VMName $vmName;
#Verify encryption is enabled on OS volume and data volumes
$OsVolumeEncryptionSettings = $encryptionStatus.OsVolumeEncryptionSettings;
Assert-AreEqual $encryptionStatus.OsVolumeEncrypted $true;
Assert-AreEqual $encryptionStatus.DataVolumesEncrypted $true;
#verify diskencryption keyvault url & kek url are not null
Assert-NotNull $OsVolumeEncryptionSettings;
Assert-NotNull $OsVolumeEncryptionSettings.DiskEncryptionKey.SecretUrl;
Assert-NotNull $OsVolumeEncryptionSettings.DiskEncryptionKey.SourceVault;

#Add a couple of data volumes to encrypt them
$p = Add-AzureRmVMDataDisk -VM $p -Name $extraDataDiskName1 -Caching 'ReadOnly' -DiskSizeInGB 2 -Lun 1 -VhdUri $dataDiskVhdUri -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name $extraDataDiskName2 -Caching 'ReadOnly' -DiskSizeInGB 2 -Lun 1 -VhdUri $dataDiskVhdUri -CreateOption Empty;
#Enable encryption on the VM
Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName -AadClientID $aadClientID -AadClientSecret $aadClientSecret -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $keyVaultResourceId -KeyEncryptionKeyUrl $keyEncryptionKeyUrl -KeyEncryptionKeyVaultId $keyVaultResourceId -Force;
#Get encryption status
$encryptionStatus = Get-AzureRmVmDiskEncryptionStatus -ResourceGroupName $rgname -VMName $vmName;
#Verify encryption is enabled on OS volume and data volumes
$OsVolumeEncryptionSettings = $encryptionStatus.OsVolumeEncryptionSettings;
Assert-AreEqual $encryptionStatus.OsVolumeEncrypted $true;
Assert-AreEqual $encryptionStatus.DataVolumesEncrypted $true;
#verify diskencryption keyvault url & kek url are not null
Assert-NotNull $OsVolumeEncryptionSettings;
Assert-NotNull $OsVolumeEncryptionSettings.DiskEncryptionKey.SecretUrl;
Assert-NotNull $OsVolumeEncryptionSettings.DiskEncryptionKey.SourceVault;

#Disable encryption on the VM
Disable-AzureRmVMDiskEncryption -ResourceGroupName $rgname -VMName $vmName;
#Get encryption status
$encryptionStatus = Get-AzureRmVmDiskEncryptionStatus -ResourceGroupName $rgname -VMName $p.StorageProfile.OSDisk.Name;
#Verify encryption is disabled on OS volume and data volumes
$OsVolumeEncryptionSettings = $encryptionStatus.OsVolumeEncryptionSettings;
Assert-AreEqual $encryptionStatus.OsVolumeEncrypted $false;
Assert-AreEqual $encryptionStatus.DataVolumesEncrypted $false;

#Remove AzureDiskEncryption extension
Remove-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName;
#Get encryption status again to make sure it's the same as before when the extension was installed
$encryptionStatus = Get-AzureRmVmDiskEncryptionStatus -ResourceGroupName $rgname -VMName $vmName;
#Verify encryption is disabled on OS volume and data volumes
$OsVolumeEncryptionSettings = $encryptionStatus.OsVolumeEncryptionSettings;
Assert-AreEqual $encryptionStatus.OsVolumeEncrypted $false;
Assert-AreEqual $encryptionStatus.DataVolumesEncrypted $false;

#Enable encryption on the VM
Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName -AadClientID $aadClientID -AadClientSecret $aadClientSecret -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $keyVaultResourceId -KeyEncryptionKeyUrl $keyEncryptionKeyUrl -KeyEncryptionKeyVaultId $keyVaultResourceId -Force;
#Get encryption status
$encryptionStatus = Get-AzureRmVmDiskEncryptionStatus -ResourceGroupName $rgname -VMName $vmName;
#Verify encryption is enabled on OS volume and data volumes
$OsVolumeEncryptionSettings = $encryptionStatus.OsVolumeEncryptionSettings;
Assert-AreEqual $encryptionStatus.OsVolumeEncrypted $true;
Assert-AreEqual $encryptionStatus.DataVolumesEncrypted $true;
#verify diskencryption keyvault url & kek url are not null
Assert-NotNull $OsVolumeEncryptionSettings;
Assert-NotNull $OsVolumeEncryptionSettings.DiskEncryptionKey.SecretUrl;
Assert-NotNull $OsVolumeEncryptionSettings.DiskEncryptionKey.SourceVault;

#Remove the VM
Remove-AzureRmVm -ResourceGroupName $rgname -Name $vmName -Force;
Expand All @@ -1041,12 +1117,12 @@ function Test-AzureDiskEncryptionExtension
$p = Set-AzureRmVMOSDisk -VM $p -Name $p.StorageProfile.OSDisk.Name -VhdUri $p.StorageProfile.OSDisk.Vhd.Uri -Caching ReadWrite -CreateOption attach -DiskEncryptionKeyUrl $encryptionStatus.OsVolumeEncryptionSettings.DiskEncryptionKey.SecretUrl -DiskEncryptionKeyVaultId $encryptionStatus.OsVolumeEncryptionSettings.DiskEncryptionKey.SourceVault.Id -Windows;

New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;

}
finally
{
# Cleanup
Remove-AzureRmResourceGroup -Name $rgname -Force;
Clean-ResourceGroup $rgname;
#Remove-AzureRmADApplication -ApplicationObjectId $ADApp.ApplicationId -Force;
}
}

Expand Down Expand Up @@ -1306,7 +1382,10 @@ function Test-VirtualMachineExtensionWithSwitch
# Set extension settings by raw strings
$settingstr = '{"fileUris":[],"commandToExecute":""}';
$protectedsettingstr = '{"storageAccountName":"' + $stoname + '","storageAccountKey":"' + $stokey + '"}';
Set-AzureRmVMExtension -ResourceGroupName $rgname -Location $loc -VMName $vmname -Name $extname -Publisher $publisher -ExtensionType $exttype -TypeHandlerVersion $extver -SettingString $settingstr -ProtectedSettingString $protectedsettingstr -DisableAutoUpgradeMinorVersion -ForceRerun
Set-AzureRmVMExtension -ResourceGroupName $rgname -Location $loc -VMName $vmname `
-Name $extname -Publisher $publisher `
-ExtensionType $exttype -TypeHandlerVersion $extver -SettingString $settingstr -ProtectedSettingString $protectedsettingstr `
-DisableAutoUpgradeMinorVersion -ForceRerun "RerunExtension";

# Get VM Extension
$ext = Get-AzureRmVMExtension -ResourceGroupName $rgname -VMName $vmname -Name $extname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ function Test-VirtualMachineProfile
Assert-AreEqual $timeZone $p.OSProfile.WindowsConfiguration.TimeZone;

# Verify Additional Unattend Content
Assert-AreEqual "Microsoft-Windows-Shell-Setup" $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[0].ComponentName;
#Assert-AreEqual "Microsoft-Windows-Shell-Setup" $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[0].ComponentName;
Assert-AreEqual $aucContent $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[0].Content;
Assert-AreEqual "oobeSystem" $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[0].PassName;
Assert-AreEqual $aucSetting $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[0].SettingName;
Assert-AreEqual "Microsoft-Windows-Shell-Setup" $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[1].ComponentName;
#Assert-AreEqual "Microsoft-Windows-Shell-Setup" $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[1].ComponentName;
Assert-AreEqual $aucContent $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[1].Content;
Assert-AreEqual "oobeSystem" $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[1].PassName;
Assert-AreEqual $aucSetting $p.OSProfile.WindowsConfiguration.AdditionalUnattendContent[1].SettingName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ function Test-VirtualMachinePiping
# VM Profile & Hardware
$vmsize = 'Standard_A4';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;

# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
Expand All @@ -252,16 +250,6 @@ function Test-VirtualMachinePiping
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;

$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;

# Adding the same Nic but not set it Primary
$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId -Primary;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Primary $true;

# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
Expand All @@ -275,23 +263,6 @@ function Test-VirtualMachinePiping
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";

$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;

Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;
Assert-AreEqual $p.StorageProfile.DataDisks.Count 2;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB 10;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun 1;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Vhd.Uri $dataDiskVhdUri1;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[1].DiskSizeGB 11;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Lun 2;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Vhd.Uri $dataDiskVhdUri2;

# OS & Image
$user = "Foo12";
$password = 'BaR@123' + $rgname;
Expand All @@ -300,23 +271,15 @@ function Test-VirtualMachinePiping
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";

$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize `
| Add-AzureRmVMNetworkInterface -Id $nicId -Primary `
| Set-AzureRmVMOSDisk -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage `
| Add-AzureRmVMDataDisk -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty `
| Add-AzureRmVMDataDisk -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty `
| Set-AzureRmVMOperatingSystem -Windows -ComputerName $computerName -Credential $cred;

$imgRef = Get-DefaultCRPImage -loc $loc;
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);

Assert-AreEqual $p.OSProfile.AdminUsername $user;
Assert-AreEqual $p.OSProfile.ComputerName $computerName;
Assert-AreEqual $p.OSProfile.AdminPassword $password;

Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer;
Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName;
Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus;
Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version;

# Virtual Machine
# TODO: Still need to do retry for New-AzureRmVM for SA, even it's returned in Get-.
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;
$imgRef | Set-AzureRmVMSourceImage -VM $p | New-AzureRmVM -ResourceGroupName $rgname -Location $loc;

# Get VM
$vm1 = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;
Expand Down
Loading