Skip to content

Commit 64d6b8b

Browse files
Merge pull request #188 from Azure/mergebranch
Adding changes in master to vnext branch
2 parents 76081e7 + 1ca17c4 commit 64d6b8b

17 files changed

Lines changed: 409 additions & 140 deletions

CanaryValidator/Canary.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ param (
106106
[switch]$ListAvailable
107107
)
108108

109-
#Requires -Modules AzureRM
109+
#requires -Modules AzureRM.Profile, AzureRM.AzureStackAdmin
110110
#Requires -RunAsAdministrator
111111
Import-Module -Name $PSScriptRoot\Canary.Utilities.psm1 -Force -DisableNameChecking
112112
Import-Module -Name $PSScriptRoot\..\Connect\AzureStack.Connect.psm1 -Force

ComputeAdmin/AzureStack.ComputeAdmin.psm1

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ function Add-AzureStackVMSSGalleryItem {
2323
}
2424

2525
$fileName = "microsoft.vmss.1.3.6.azpkg"
26+
$basePath = (Get-Module AzureStack.ComputeAdmin).ModuleBase
2627

27-
$blob = $container| Set-AzureStorageBlobContent –File ([System.IO.Path]::GetDirectoryName($PSCommandPath) + "\" + $fileName) –Blob $fileName -Force
28+
$blob = Set-AzureStorageBlobContent –File ($basePath + "\" + $fileName) –Blob $fileName -Container $cName -Force
29+
$container = Get-AzureStorageContainer -Name $cName -ErrorAction SilentlyContinue
2830

2931
$uri = $blob.Context.BlobEndPoint + $container.Name + "/" + $blob.Name
3032

@@ -160,9 +162,9 @@ Function Add-VMImage{
160162
#same for storage
161163
$storageAccount = Get-AzureRmStorageAccount -Name $storageAccountName -ResourceGroupName $resourceGroupName -ErrorAction SilentlyContinue
162164
if (-not ($storageAccount)) {
163-
$storageAccount = New-AzureRmStorageAccount -Name $storageAccountName -Location $location -ResourceGroupName $resourceGroupName -Type Standard_LRS
165+
$storageAccount = New-AzureRmStorageAccount -Name $storageAccountName -Location $location -ResourceGroupName $resourceGroupName -Type Standard_LRS
164166
}
165-
Set-AzureRmCurrentStorageAccount -StorageAccountName $storageAccountName -ResourceGroupName $resourceGroupName
167+
Set-AzureRmCurrentStorageAccount -StorageAccountName $storageAccountName -ResourceGroupName $resourceGroupName
166168
#same for container
167169
$container = Get-AzureStorageContainer -Name $containerName -ErrorAction SilentlyContinue
168170
if (-not ($container)) {
@@ -297,11 +299,7 @@ Function Add-VMImage{
297299
$galleryItemURI = '{0}{1}/{2}' -f $storageAccount.PrimaryEndpoints.Blob.AbsoluteUri, $containerName,$galleryItem.Name
298300

299301

300-
if((Get-Module AzureStack).Version -ge [System.Version] "1.2.9"){
301-
Add-AzureRMGalleryItem -GalleryItemUri $galleryItemURI
302-
}else{
303-
Add-AzureRMGalleryItem -SubscriptionId $subscription -GalleryItemUri $galleryItemURI -ApiVersion 2015-04-01
304-
}
302+
Add-AzureRMGalleryItem -GalleryItemUri $galleryItemURI
305303

306304
#cleanup
307305
Remove-Item $GalleryItem
@@ -383,12 +381,7 @@ Function Remove-VMImage{
383381
$name = "$offer$sku"
384382
#Remove periods so that the offer and sku can be retrieved from the Marketplace Item name
385383
$name =$name -replace "\.","-"
386-
if((Get-Module AzureStack).Version -ge [System.Version] "1.2.9"){
387-
Get-AzureRMGalleryItem | Where-Object {$_.Name -contains "$publisher.$name.$version"} | Remove-AzureRMGalleryItem
388-
}else{
389-
Get-AzureRMGalleryItem -ApiVersion 2015-04-01 | Where-Object {$_.Name -contains "$publisher.$name.$version"} | Remove-AzureRMGalleryItem -ApiVersion 2015-04-01
390-
}
391-
384+
Get-AzureRMGalleryItem | Where-Object {$_.Name -contains "$publisher.$name.$version"} | Remove-AzureRMGalleryItem
392385
}
393386

394387
}
@@ -431,7 +424,8 @@ function New-Server2016VMImage {
431424
[Parameter()]
432425
[bool] $CreateGalleryItem = $true,
433426

434-
[switch] $Net35
427+
[Parameter()]
428+
[bool] $Net35 = $true
435429
)
436430
begin {
437431
function CreateWindowsVHD {
@@ -460,7 +454,7 @@ function New-Server2016VMImage {
460454
Write-Verbose -Message "Preparing VHD"
461455

462456
$VHDMount = Mount-DiskImage -ImagePath $VHDPath -PassThru -ErrorAction Stop
463-
$disk = $VHDMount | Get-DiskImage | Get-Disk -ErrorAction Stop
457+
$disk = $VHDMount | Get-DiskImage -ErrorAction Stop | Get-Disk -ErrorAction SilentlyContinue
464458
$disk | Initialize-Disk -PartitionStyle MBR -ErrorAction Stop
465459
$partition = New-Partition -UseMaximumSize -Disknumber $disk.DiskNumber -IsActive:$True -AssignDriveLetter -ErrorAction Stop
466460
$volume = Format-Volume -Partition $partition -FileSystem NTFS -confirm:$false -ErrorAction Stop
@@ -818,7 +812,6 @@ Function Add-VMExtension{
818812

819813
[Parameter(Mandatory=$true, ParameterSetName='VMExtensionFromLocal')]
820814
[Parameter(Mandatory=$true, ParameterSetName='VMExtesionFromAzure')]
821-
[ValidatePattern(\d+\.\d+\.\d+)]
822815
[String] $version,
823816

824817
[Parameter(ParameterSetName='VMExtensionFromLocal')]
@@ -904,7 +897,7 @@ Function Add-VMExtension{
904897
$uri = $armEndpoint + '/subscriptions/' + $subscription + '/providers/Microsoft.Compute.Admin/locations/' + $location + '/artifactTypes/VMExtension/publishers/' + $publisher
905898
$uri = $uri + '/types/' + $type + '/versions/' + $version + '?api-version=2015-12-01-preview'
906899

907-
Log-Info $uri
900+
Write-Verbose $uri
908901

909902
#building request body JSON
910903
if($pscmdlet.ParameterSetName -eq "VMExtensionFromLocal") {
@@ -958,10 +951,9 @@ Function Remove-VMExtension{
958951
[String] $publisher,
959952

960953
[Parameter(Mandatory=$true)]
961-
[ValidatePattern(\d+\.\d+\.\d+)]
962954
[String] $version,
963955

964-
[String] $type = "CustomScriptExtension",
956+
[String] $type,
965957

966958
[Parameter(Mandatory=$true)]
967959
[ValidateSet('Windows' ,'Linux')]
@@ -989,7 +981,7 @@ Function Remove-VMExtension{
989981
$uri = $armEndpoint + '/subscriptions/' + $subscription + '/providers/Microsoft.Compute.Admin/locations/' + $location + '/artifactTypes/VMExtension/publishers/' + $publisher
990982
$uri = $uri + '/types/' + $type + '/versions/' + $version + '?api-version=2015-12-01-preview'
991983

992-
Log-Info $uri
984+
Write-Verbose $uri
993985

994986
try{
995987
Invoke-RestMethod -Method DELETE -Uri $uri -ContentType 'application/json' -Headers $headers

ComputeAdmin/README.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@ Import-Module ..\Connect\AzureStack.Connect.psm1
1515
Import-Module .\AzureStack.ComputeAdmin.psm1
1616
```
1717

18-
Adding a VM Image requires that you obtain the GUID value of your Directory Tenant. If you know the non-GUID form of the Azure Active Directory Tenant used to deploy your Azure Stack instance, you can retrieve the GUID value with the following:
18+
You will need to reference your Azure Stack Administrator environment. To create an administrator environment use the below. The ARM endpoint below is the administrator default for a one-node environment.
1919

2020
```powershell
21-
$aadTenant = Get-AADTenantGUID -AADTenantName "<myaadtenant>.onmicrosoft.com"
21+
Add-AzureStackAzureRmEnvironment -Name "AzureStackAdmin" -ArmEndpoint "https://adminmanagement.local.azurestack.external"
2222
```
2323

24-
Otherwise, it can be retrieved directly from your Azure Stack deployment. This method can also be used for AD FS. First, add your host to the list of TrustedHosts:
24+
Adding a VM Image requires that you obtain the value of your Directory Tenant ID. For **Azure Active Directory** environments provide your directory tenant name:
25+
2526
```powershell
26-
Set-Item wsman:\localhost\Client\TrustedHosts -Value "<Azure Stack host address>" -Concatenate
27+
$TenantID = Get-DirectoryTenantID -AADTenantName "<mydirectorytenant>.onmicrosoft.com" -EnvironmentName AzureStackAdmin
2728
```
28-
Then execute the following:
29+
30+
For **ADFS** environments use the following:
31+
2932
```powershell
30-
$Password = ConvertTo-SecureString "<Admin password provided when deploying Azure Stack>" -AsPlainText -Force
31-
$AadTenant = Get-AzureStackAadTenant -HostComputer <Host IP Address> -Password $Password
33+
$TenantID = Get-DirectoryTenantID -ADFS -EnvironmentName AzureStackAdmin
3234
```
3335

3436
## Add the WS2016 Evaluation VM Image
@@ -37,16 +39,10 @@ The New-Server2016VMImage allows you to add a Windows Server 2016 Evaluation VM
3739

3840
As a prerequisite, you need to obtain the Windows Server 2016 Evaluation ISO which can be found [here](https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2016).
3941

40-
You will need to reference your Azure Stack Administrator environment. To create an administrator environment use the below. The ARM endpoint below is the administrator default for a one-node environment.
41-
42-
```powershell
43-
Add-AzureStackAzureRmEnvironment -Name "AzureStackAdmin" -ArmEndpoint "https://adminmanagement.local.azurestack.external"
44-
```
45-
4642
An example usage is the following:
4743
```powershell
4844
$ISOPath = "<Path to ISO>"
49-
New-Server2016VMImage -ISOPath $ISOPath -TenantId $aadTenant -EnvironmentName "AzureStackAdmin"
45+
New-Server2016VMImage -ISOPath $ISOPath -TenantId $TenantID -EnvironmentName "AzureStackAdmin"
5046
```
5147
Please make sure to specify the correct administrator ARM endpoint for your environment.
5248

@@ -116,7 +112,7 @@ An example usage is the following:
116112

117113
```powershell
118114
$path = "<Path to vm extension zip>"
119-
Add-VMExtension -publisher "Publisher" -type "Type" -version $version -extensionLocalPath $path -osType Windows -tenantID $aadTenant -azureStackCredentials $azureStackCredentials -EnvironmentName "AzureStackAdmin"
115+
Add-VMExtension -publisher "Publisher" -type "Type" -version "1.0.0.0" -extensionLocalPath $path -osType Windows -tenantID $TenantID -azureStackCredentials $azureStackCredentials -EnvironmentName "AzureStackAdmin"
120116
```
121117

122118

@@ -130,7 +126,7 @@ Add-AzureStackAzureRmEnvironment -Name "AzureStackAdmin" -ArmEndpoint "https://a
130126
Run the below command to remove an uploaded VM extension.
131127

132128
```powershell
133-
Remove-VMExtension -publisher "Publisher" -type "Type" -version "1.0.0.0" -osType Windows -tenantID $tenantId -azureStackCredentials $azureStackCredentials -EnvironmentName "AzureStackAdmin"
129+
Remove-VMExtension -publisher "Publisher" -type "Type" -version "1.0.0.0" -osType Windows -tenantID $TenantID -azureStackCredentials $azureStackCredentials -EnvironmentName "AzureStackAdmin"
134130
```
135131

136132
## VM Scale Set gallery item

ComputeAdmin/Tests/ComputeAdmin.Tests.ps1

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,7 @@ InModuleScope $script:ModuleName {
8585
It 'Remove-VMImage and Removing Marketplace Item should successfully complete' {
8686
{
8787
Remove-VMImage -publisher $publisher -offer $offer -sku $gallerySku -version $version -tenantID $AadTenant -EnvironmentName $EnvironmentName -AzureStackCredential $stackLoginCreds
88-
if((Get-Module AzureStack).Version -ge [System.Version] "1.2.9"){
89-
Get-AzureRMGalleryItem
90-
Get-AzureRMGalleryItem | Where-Object {$_.Name -contains "$publisher.$offer$gallerySku.$version"} | Remove-AzureRMGalleryItem
91-
}else{
92-
Get-AzureRMGalleryItem -ApiVersion 2015-04-01
93-
Get-AzureRMGalleryItem -ApiVersion 2015-04-01 | Where-Object {$_.Name -contains "$publisher.$offer$gallerySku.$version"} | Remove-AzureRMGalleryItem -ApiVersion 2015-04-01
94-
}
88+
Get-AzureRMGalleryItem | Where-Object {$_.Name -contains "$publisher.$offer$gallerySku.$version"} | Remove-AzureRMGalleryItem
9589
} | Should Not Throw
9690
}
9791

@@ -109,11 +103,7 @@ InModuleScope $script:ModuleName {
109103
Remove-VMImage -publisher $newPub -offer $newOffer -sku $newSKU -version $newVersion -tenantID $AadTenant -EnvironmentName $EnvironmentName -AzureStackCredential $stackLoginCreds
110104
$GalleryItemName = "$newOffer$newSKU"
111105
$GalleryItemName = $GalleryItemName -replace "\.","-"
112-
if((Get-Module AzureStack).Version -ge [System.Version] "1.2.9"){
113-
Get-AzureRMGalleryItem | Where-Object {$_.Name -contains "$newPub.$GalleryItemName.$newVersion"} | Remove-AzureRMGalleryItem
114-
}else{
115-
Get-AzureRMGalleryItem -ApiVersion 2015-04-01 | Where-Object {$_.Name -contains "$newPub.$GalleryItemName.$newVersion"} | Remove-AzureRMGalleryItem -ApiVersion 2015-04-01
116-
}
106+
Get-AzureRMGalleryItem | Where-Object {$_.Name -contains "$newPub.$GalleryItemName.$newVersion"} | Remove-AzureRMGalleryItem
117107
} | Should Not Throw
118108
}
119109

Connect/AzureStack.Connect.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See LICENSE.txt in the project root for license information.
33

44
#requires -Version 4.0
5-
#requires -Modules AzureRM.Profile, VpnClient, AzureStack
5+
#requires -Modules AzureRM.Profile, VpnClient, AzureRM.AzureStackAdmin
66

77
<#
88
.SYNOPSIS
@@ -128,7 +128,7 @@ function Add-AzureStackAzureRmEnvironment {
128128
$armEnv = Get-AzureRmEnvironment -Name $Name
129129
if($armEnv -ne $null) {
130130
Write-Verbose "Updating AzureRm environment $Name" -Verbose
131-
Remove-AzureRmEnvironment -Name $Name | Out-Null
131+
Remove-AzureRmEnvironment -Name $Name -Force | Out-Null
132132
}
133133
else {
134134
Write-Verbose "Adding AzureRm environment $Name" -Verbose

Connect/README.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,44 +70,40 @@ See the [Azure Stack Install PowerShell](https://docs.microsoft.com/en-us/azure/
7070

7171
AzureRM cmdlets can be targeted at multiple Azure clouds such as Azure China, Government, and Azure Stack.
7272

73-
Connecting requires that you obtain the GUID value of your Directory Tenant. If you know the non-GUID form of the Azure Active Directory Tenant used to deploy your Azure Stack instance, you can retrieve the GUID value with the following:
73+
To target your Azure Stack instance as a tenant, an AzureRM environment needs to be registered as follows. The ARM endpoint below is the tenant default for a one-node environment.
7474

7575
```powershell
76-
$aadTenant = Get-AADTenantGUID -AADTenantName "<myaadtenant>.onmicrosoft.com"
76+
Add-AzureStackAzureRmEnvironment -Name AzureStack -ArmEndpoint "https://management.local.azurestack.external"
7777
```
7878

79-
Otherwise, your home directory can be retrieved directly from your Azure Stack deployment. This method can also be used for AD FS. First, add your host to the list of TrustedHosts:
80-
```powershell
81-
Set-Item wsman:\localhost\Client\TrustedHosts -Value "<Azure Stack host address>" -Concatenate
82-
```
83-
Then execute the following:
79+
To create an administrator environment use the below. The ARM endpoint below is the administrator default for a one-node environment.
80+
8481
```powershell
85-
$Password = ConvertTo-SecureString "<Admin password provided when deploying Azure Stack>" -AsPlainText -Force
86-
$AadTenant = Get-AzureStackAadTenant -HostComputer <Host IP Address> -Password $Password
82+
Add-AzureStackAzureRmEnvironment -Name AzureStackAdmin -ArmEndpoint "https://adminmanagement.local.azurestack.external"
8783
```
8884

89-
To target your Azure Stack instance as a tenant, an AzureRM environment needs to be registered as follows. The ARM endpoint below is the tenant default for a one-node environment.
85+
Connecting to your environment requires that you obtain the value of your Directory Tenant ID. For **Azure Active Directory** environments provide your directory tenant name:
9086

9187
```powershell
92-
Add-AzureStackAzureRmEnvironment -Name AzureStack -ArmEndpoint "https://management.local.azurestack.external"
88+
$TenantID = Get-DirectoryTenantID -AADTenantName "<mydirectorytenant>.onmicrosoft.com" -EnvironmentName AzureStackAdmin
9389
```
9490

95-
To create an administrator environment use the below. The ARM endpoint below is the administrator default for a one-node environment.
91+
For **ADFS** environments use the following:
9692

9793
```powershell
98-
Add-AzureStackAzureRmEnvironment -Name AzureStackAdmin -ArmEndpoint "https://adminmanagement.local.azurestack.external"
94+
$TenantID = Get-DirectoryTenantID -ADFS -EnvironmentName AzureStackAdmin
9995
```
10096

10197
After registering the AzureRM environment, cmdlets can be easily targeted at your Azure Stack instance. For example:
10298

10399
```powershell
104-
Login-AzureRmAccount -EnvironmentName "AzureStack" -TenantId $AadTenant
100+
Login-AzureRmAccount -EnvironmentName "AzureStack" -TenantId $TenantID
105101
```
106102

107103
Similarly, for targeting the administrator endpoints:
108104

109105
```powershell
110-
Login-AzureRmAccount -EnvironmentName "AzureStackAdmin" -TenantId $AadTenant
106+
Login-AzureRmAccount -EnvironmentName "AzureStackAdmin" -TenantId $TenantID
111107
```
112108

113109
## Register Azure RM Providers on new subscriptions

Connect/Tests/Connect.Tests.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ InModuleScope $script:ModuleName {
9393
}
9494

9595
It 'Add-AzureStackAzureRmEnvironment should successfully add a an administrator environment' {
96-
Remove-AzureRmEnvironment -Name $EnvironmentName -ErrorAction SilentlyContinue
9796
Add-AzureStackAzureRmEnvironment -ArmEndpoint $armEndpoint -Name $EnvironmentName
9897
Get-AzureRmEnvironment -Name $EnvironmentName | Should Not Be $null
9998
}

Deployment/PrepareBootFromVHD.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ The AdminPassword parameter is only used when the ApplyUnnatend parameter is set
3535
.EXAMPLE 
3636
 
3737
Prepare the host to boot from cloudbuilder.vhdx. This requires KVM access to the host for configuring the Operating System.
38-
.\PrepareBootFromVHD.ps1 -CloudBuilderPath c:\CloudBuilder.vhdx -DriverPath c:\VhdDrivers
38+
.\PrepareBootFromVHD.ps1 -CloudBuilderDiskPath c:\CloudBuilder.vhdx -DriverPath c:\VhdDrivers
3939
 
4040
.EXAMPLE  
4141
 
4242
Prepare the host to boot from cloudbuilder.vhdx. The Operating System is automatically configured with an unattend.xml.
43-
.\PrepareBootFromVHD.ps1 -CloudBuilderPath c:\CloudBuilder.vhdx -ApplyUnattend
43+
.\PrepareBootFromVHD.ps1 -CloudBuilderDiskPath c:\CloudBuilder.vhdx -ApplyUnattend
4444
  
4545
.NOTES 
4646
 

0 commit comments

Comments
 (0)