Skip to content

Commit 48727e6

Browse files
committed
New Subscriptions for AzureStack 1.5.0
1 parent 936370a commit 48727e6

37 files changed

+609
-459
lines changed

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Azs.Subscriptions.Admin.psd1

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Licensed under the MIT License. See License.txt in the project root for license
1717
RootModule = 'Azs.Subscriptions.Admin.psm1'
1818

1919
# Version number of this module.
20-
ModuleVersion = '0.2.0'
20+
ModuleVersion = '0.3.0'
2121

2222
# Supported PSEditions
2323
# CompatiblePSEditions = @()
@@ -56,8 +56,8 @@ Licensed under the MIT License. See License.txt in the project root for license
5656
# ProcessorArchitecture = ''
5757

5858
# Modules that must be imported into the global environment prior to importing this module
59-
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; RequiredVersion = '3.4.1'; },
60-
@{ModuleName = 'AzureRM.Resources'; RequiredVersion = '4.4.1'; })
59+
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.3.4'; },
60+
@{ModuleName = 'AzureRM.Resources'; ModuleVersion = '6.0.2'; })
6161

6262
# Assemblies that must be loaded prior to importing this module
6363
# RequiredAssemblies = @()
@@ -121,19 +121,30 @@ Licensed under the MIT License. See License.txt in the project root for license
121121
PSData = @{
122122

123123
# Tags applied to this module. These help with module discovery in online galleries.
124-
# Tags = @()
124+
Tags = @('AzureStack', 'Azure Stack', 'Admin', 'Subscriptions', 'Azure Stack Admin Subscription', 'Offer', 'Plan', 'Managed')
125125

126126
# A URL to the license for this module.
127-
# LicenseUri = ''
127+
LicenseUri = 'https://aka.ms/azps-license'
128128

129129
# A URL to the main website for this project.
130-
# ProjectUri = ''
130+
ProjectUri = 'https://github.com/Azure/azure-powershell'
131131

132132
# A URL to an icon representing this module.
133133
# IconUri = ''
134134

135135
# ReleaseNotes of this module
136-
# ReleaseNotes = ''
136+
ReleaseNotes = '## 2018.8.12 - Version 0.2.0
137+
* Module dependencies updated
138+
* AzureRM.Profile >= 5.3.4
139+
* AzureRM.Resources >= 6.0.2
140+
* Support handling names of nested resources
141+
* TODO
142+
* Deprecations
143+
* Get-AzsDelegatedProviderManagedOffer, the parameter DelegatedProvider is now an alias for DelegatedProviderId
144+
* TODO
145+
* Bug fixes
146+
* Handle ErrrorAction correctly now
147+
'
137148

138149
} # End of PSData hashtable
139150

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Azs.Subscriptions.Admin.psm1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ if (Test-Path -Path $ClrPath -PathType Container) {
2929
. (Join-Path -Path $PSScriptRoot -ChildPath 'Get-ApplicableFilters.ps1')
3030
. (Join-Path -Path $PSScriptRoot -ChildPath 'Test-FilteredResult.ps1')
3131
. (Join-Path -Path $PSScriptRoot -ChildPath 'Get-ArmResourceIdParameterValue.ps1')
32+
. (Join-Path -Path $PSScriptRoot -ChildPath 'Get-ResourceNameSuffix.ps1')
3233
$allPs1FilesPath = Join-Path -Path $PSScriptRoot -ChildPath 'Generated.PowerShell.Commands' | Join-Path -ChildPath '*.ps1'
3334
Get-ChildItem -Path $allPs1FilesPath -Recurse -File | ForEach-Object { . $_.FullName}

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Add-AzsPlanToOffer.ps1

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -77,61 +77,53 @@ function Add-AzsPlanToOffer {
7777

7878
Process {
7979

80-
81-
8280
if ($PSCmdlet.ShouldProcess("$PlanName to $OfferName" , "Connect plan to offer")) {
8381

84-
$dontCheck = $true
85-
try {
86-
$_offer = Get-AzsManagedOffer -Name $OfferName -ResourceGroupName $ResourceGroupName
87-
$_planId = $_offer.BasePlanIds | Where-Object { $_ -like "*$PlanName" }
88-
$_plan = Get-AzsPlan -ResourceId $_planId
89-
$dontCheck = $_plan -eq $null
90-
} catch {
91-
# No-op
82+
$_offer = Get-AzsManagedOffer -Name $OfferName -ResourceGroupName $ResourceGroupName
83+
$_planId = $_offer.BasePlanIds | Where-Object { $_ -like "*$PlanName" }
84+
if ($null -ne (Get-AzsPlan -ResourceId $_planId -ErrorAction SilentlyContinue)) {
85+
Write-Error "A plan with the name $Name under the offer $Offername in the resource group $resourceGroupName already exists"
86+
return
9287
}
9388

94-
if ($dontCheck -or ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Connect the plan to the offer?", "Performing operation link plan to offer with $PlanName to $OfferName."))) {
95-
96-
$NewServiceClient_params = @{
97-
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscriptions.Admin.SubscriptionsAdminClient'
98-
}
89+
$NewServiceClient_params = @{
90+
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscriptions.Admin.SubscriptionsAdminClient'
91+
}
9992

100-
$GlobalParameterHashtable = @{}
101-
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
93+
$GlobalParameterHashtable = @{}
94+
$NewServiceClient_params['GlobalParameterHashtable'] = $GlobalParameterHashtable
10295

103-
$GlobalParameterHashtable['SubscriptionId'] = $null
104-
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
105-
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
106-
}
96+
$GlobalParameterHashtable['SubscriptionId'] = $null
97+
if ($PSBoundParameters.ContainsKey('SubscriptionId')) {
98+
$GlobalParameterHashtable['SubscriptionId'] = $PSBoundParameters['SubscriptionId']
99+
}
107100

108-
$SubscriptionsAdminClient = New-ServiceClient @NewServiceClient_params
101+
$SubscriptionsAdminClient = New-ServiceClient @NewServiceClient_params
109102

110103

111-
$flattenedParameters = @('PlanName', 'PlanLinkType', 'MaxAcquisitionCount')
112-
$utilityCmdParams = @{}
113-
$flattenedParameters | ForEach-Object {
114-
if ($PSBoundParameters.ContainsKey($_)) {
115-
$utilityCmdParams[$_] = $PSBoundParameters[$_]
116-
}
104+
$flattenedParameters = @('PlanName', 'PlanLinkType', 'MaxAcquisitionCount')
105+
$utilityCmdParams = @{}
106+
$flattenedParameters | ForEach-Object {
107+
if ($PSBoundParameters.ContainsKey($_)) {
108+
$utilityCmdParams[$_] = $PSBoundParameters[$_]
117109
}
118-
$PlanLink = New-PlanLinkDefinitionObject @utilityCmdParams
119-
120-
Write-Verbose -Message 'Performing operation link on $SubscriptionsAdminClient.'
121-
$TaskResult = $SubscriptionsAdminClient.Offers.LinkWithHttpMessagesAsync($ResourceGroupName, $OfferName, $PlanLink)
110+
}
111+
$PlanLink = New-PlanLinkDefinitionObject @utilityCmdParams
122112

123-
if ($TaskResult) {
124-
$GetTaskResult_params = @{
125-
TaskResult = $TaskResult
126-
}
113+
Write-Verbose -Message 'Performing operation link on $SubscriptionsAdminClient.'
114+
$TaskResult = $SubscriptionsAdminClient.Offers.LinkWithHttpMessagesAsync($ResourceGroupName, $OfferName, $PlanLink)
127115

128-
Get-TaskResult @GetTaskResult_params
116+
if ($TaskResult) {
117+
$GetTaskResult_params = @{
118+
TaskResult = $TaskResult
119+
}
129120

130-
if ($TaskResult.IsFaulted -ne $true) {
131-
Get-AzsPlan -ResourceGroupName $ResourceGroupName -Name $PlanName
132-
}
121+
Get-TaskResult @GetTaskResult_params
133122

123+
if ($TaskResult.IsFaulted -ne $true) {
124+
Get-AzsPlan -ResourceGroupName $ResourceGroupName -Name $PlanName
134125
}
126+
135127
}
136128
}
137129
}

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Get-AzsDelegatedProvider.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Get-AzsDelegatedProvider
3232
param(
3333
[Parameter(Mandatory = $true, ParameterSetName = 'Get', Position = 0)]
3434
[ValidateNotNullOrEmpty()]
35-
[System.String]
35+
[System.Guid]
3636
$DelegatedProviderId
3737
)
3838

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Get-AzsDelegatedProviderManagedOffer.ps1

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Licensed under the MIT License. See License.txt in the project root for license
1010
.DESCRIPTION
1111
Get the list of delegated provider offers.
1212
13-
.PARAMETER DelegatedProvider
13+
.PARAMETER DelegatedProviderId
1414
DelegatedProvider identifier.
1515
1616
.PARAMETER Name
@@ -38,8 +38,9 @@ function Get-AzsDelegatedProviderManagedOffer {
3838
[Parameter(Mandatory = $true, ParameterSetName = 'List')]
3939
[Parameter(Mandatory = $true, ParameterSetName = 'Get')]
4040
[ValidateNotNullOrEmpty()]
41+
[Alias('DelegatedProvider')]
4142
[System.String]
42-
$DelegatedProvider,
43+
$DelegatedProviderId,
4344

4445
[Parameter(Mandatory = $true, ParameterSetName = 'Get')]
4546
[ValidateNotNullOrEmpty()]
@@ -74,7 +75,11 @@ function Get-AzsDelegatedProviderManagedOffer {
7475

7576
Process {
7677

77-
78+
if ($PSBoundParameters.ContainsKey('DelegatedProviderId')) {
79+
if ( $MyInvocation.Line -match "\s-DelegatedProvider\s") {
80+
Write-Warning -Message "The parameter alias DelegatedProvider will be deprecated in future release. Please use the parameter DelegatedProviderId instead"
81+
}
82+
}
7883

7984
$NewServiceClient_params = @{
8085
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscriptions.Admin.SubscriptionsAdminClient'
@@ -90,26 +95,23 @@ function Get-AzsDelegatedProviderManagedOffer {
9095

9196
$SubscriptionsAdminClient = New-ServiceClient @NewServiceClient_params
9297

93-
$Offer = $Name
94-
9598
if ('ResourceId' -eq $PsCmdlet.ParameterSetName) {
9699
$GetArmResourceIdParameterValue_params = @{
97100
IdTemplate = '/subscriptions/{subscriptionId}/providers/Microsoft.Subscriptions.Admin/delegatedProviders/{delegatedProvider}/offers/{offer}'
98101
}
99-
100102
$GetArmResourceIdParameterValue_params['Id'] = $ResourceId
101103
$ArmResourceIdParameterValues = Get-ArmResourceIdParameterValue @GetArmResourceIdParameterValue_params
102-
$delegatedProvider = $ArmResourceIdParameterValues['delegatedProvider']
103104

104-
$offer = $ArmResourceIdParameterValues['offer']
105+
$DelegatedProviderId = $ArmResourceIdParameterValues['delegatedProvider']
106+
$Name = $ArmResourceIdParameterValues['offer']
105107
}
106108

107109
if ('List' -eq $PsCmdlet.ParameterSetName) {
108110
Write-Verbose -Message 'Performing operation ListWithHttpMessagesAsync on $SubscriptionsAdminClient.'
109-
$TaskResult = $SubscriptionsAdminClient.DelegatedProviderOffers.ListWithHttpMessagesAsync($DelegatedProvider)
111+
$TaskResult = $SubscriptionsAdminClient.DelegatedProviderOffers.ListWithHttpMessagesAsync($DelegatedProviderId)
110112
} elseif ('Get' -eq $PsCmdlet.ParameterSetName -or 'ResourceId' -eq $PsCmdlet.ParameterSetName) {
111113
Write-Verbose -Message 'Performing operation GetWithHttpMessagesAsync on $SubscriptionsAdminClient.'
112-
$TaskResult = $SubscriptionsAdminClient.DelegatedProviderOffers.GetWithHttpMessagesAsync($DelegatedProvider, $Offer)
114+
$TaskResult = $SubscriptionsAdminClient.DelegatedProviderOffers.GetWithHttpMessagesAsync($DelegatedProviderId, $Name)
113115
} else {
114116
Write-Verbose -Message 'Failed to map parameter set to operation method.'
115117
throw 'Module failed to find operation to execute.'

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Get-AzsDirectoryTenant.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ function Get-AzsDirectoryTenant {
7474

7575
Process {
7676

77-
78-
7977
$NewServiceClient_params = @{
8078
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscriptions.Admin.SubscriptionsAdminClient'
8179
}

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Get-AzsManagedOffer.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ function Get-AzsManagedOffer {
7777

7878
Process {
7979

80-
81-
8280
$NewServiceClient_params = @{
8381
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscriptions.Admin.SubscriptionsAdminClient'
8482
}

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Get-AzsSubscriptionPlan.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ function Get-AzsSubscriptionPlan {
7474

7575
Process {
7676

77-
78-
7977
$NewServiceClient_params = @{
8078
FullClientTypeName = 'Microsoft.AzureStack.Management.Subscriptions.Admin.SubscriptionsAdminClient'
8179
}

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsOffer.ps1

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ function New-AzsOffer {
117117

118118
Process {
119119

120-
121-
122120
if ($PSBoundParameters.ContainsKey('State')) {
123121
Write-Warning -Message "The parameter State will be deprecated in a future release. The State will default to the value of Private"
124122
}
@@ -142,15 +140,9 @@ function New-AzsOffer {
142140
}
143141

144142
# Validate this resource does not exist.
145-
$_objectCheck = $null
146-
try {
147-
$_objectCheck = Get-AzsManagedOffer -Name $Name -Location $Location -ResourceGroupName $ResourceGroupName
148-
} catch {
149-
# No op
150-
} finally {
151-
if ($_objectCheck -ne $null) {
152-
throw "An offer with name $Name under the resource group $ResourceGroupName at location $Location already exists."
153-
}
143+
if ($null -ne (Get-AzsManagedOffer -Name $Name -ResourceGroupName $ResourceGroupName -ErrorAction SilentlyContinue)) {
144+
Write-Error "An offer with name $Name under the resource group $ResourceGroupName at location $Location already exists."
145+
return
154146
}
155147

156148
$flattenedParameters = @('MaxSubscriptionsPerAccount', 'BasePlanIds', 'DisplayName', 'Name', 'Description', 'ExternalReferenceId', 'State', 'Location', 'SubscriptionCount', 'AddonPlanDefinition')

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsOfferDelegation.ps1

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,9 @@ function New-AzsOfferDelegation {
8585
}
8686

8787
# Validate this resource does not exist.
88-
$_objectCheck = $null
89-
try {
90-
$_objectCheck = Get-AzsOfferDelegation -ResourceGroupName $ResourceGroupName -OfferName $OfferName -Name $Name
91-
} catch {
92-
# No op
93-
} finally {
94-
if ($_objectCheck -ne $null) {
95-
throw "A delegated offer with name $Name for Offer $OfferName under the resource group $ResourceGroupName already exists."
96-
}
88+
if ($null -ne (Get-AzsOfferDelegation -ResourceGroupName $ResourceGroupName -OfferName $OfferName -Name $Name -ErrorAction SilentlyContinue)) {
89+
Write-Error "A delegated offer with name $Name for Offer $OfferName under the resource group $ResourceGroupName already exists."
90+
return
9791
}
9892

9993
$flattenedParameters = @('SubscriptionId', 'Location')

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsPlan.ps1

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,9 @@ function New-AzsPlan {
122122
}
123123

124124
# Validate this resource does not exist.
125-
$_objectCheck = $null
126-
try {
127-
$_objectCheck = Get-AzsPlan -Name $Name -ResourceGroupName $ResourceGroupName
128-
} catch {
129-
# No op
130-
} finally {
131-
if ($_objectCheck -ne $null) {
132-
throw "A plan with name $Name at under the resource group $ResourceGroupName already exists."
133-
}
125+
if ($null -ne (Get-AzsPlan -Name $Name -ResourceGroupName $ResourceGroupName -ErrorAction SilentlyContinue)) {
126+
Write-Error "A plan with name $Name at under the resource group $ResourceGroupName already exists."
127+
return
134128
}
135129

136130
# Create object

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsSubscriptionPlan.ps1

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,9 @@ function New-AzsSubscriptionPlan {
6767
if ($PSCmdlet.ShouldProcess("$AcquisitionId", "Create a subscription plan")) {
6868

6969
# Validate this resource does not exist.
70-
$_objectCheck = $null
71-
try {
72-
Write-Verbose "Checking to see if subscription plan already exists."
73-
$_objectCheck = Get-AzsSubscriptionPlan -SubscriptionId $TargetSubscriptionId -AcquisitionId $AcquisitionId
74-
} catch {
75-
# No op
76-
} finally {
77-
if ($_objectCheck -ne $null) {
78-
throw "A subscription plan with acquisition id $AcquisitionId for subscription $TargetSubscriptionId under the resource group $ResourceGroupName already exists."
79-
}
70+
if ($null -ne (Get-AzsSubscriptionPlan -TargetSubscriptionId $TargetSubscriptionId -AcquisitionId $AcquisitionId -ErrorAction SilentlyContinue)) {
71+
Write-Error "A subscription plan with acquisition id $AcquisitionId for subscription $TargetSubscriptionId under the resource group $ResourceGroupName already exists."
72+
return
8073
}
8174

8275
$flattenedParameters = @('PlanId', 'AcquisitionId')

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/New-AzsUserSubscription.ps1

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,9 @@ function New-AzsUserSubscription {
124124
if ($PSCmdlet.ShouldProcess("$SubscriptionId", "Create a new user subscription")) {
125125

126126
# Validate this resource does not exist.
127-
$_objectCheck = $null
128-
try {
129-
$_objectCheck = Get-AzsUserSubscription -SubscriptionId $SubscriptionId
130-
} catch {
131-
# No op
132-
} finally {
133-
if ($_objectCheck -ne $null) {
134-
throw "A user subsription with identifier $SubscriptionId already exists."
135-
}
127+
if ($null -ne (Get-AzsUserSubscription -SubscriptionId $SubscriptionId -ErrorAction SilentlyContinue)) {
128+
Write-Error "A user subsription with identifier $SubscriptionId already exists."
129+
return
136130
}
137131

138132
$NewServiceClient_params = @{

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Generated.PowerShell.Commands/SwaggerPathCommands/Remove-AzsSubscriptionPlan.ps1

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ function Remove-AzsSubscriptionPlan {
6565

6666
Process {
6767

68-
69-
7068
if ('ResourceId' -eq $PsCmdlet.ParameterSetName) {
7169
$GetArmResourceIdParameterValue_params = @{
7270
IdTemplate = '/subscriptions/{subscriptionId}/providers/Microsoft.Subscriptions.Admin/subscriptions/{targetSubscriptionId}/acquiredPlans/{planAcquisitionId}'

src/StackAdmin/Azs.Subscriptions.Admin/Module/Azs.Subscriptions.Admin/Get-ApplicableFilters.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function Get-ApplicableFilters {
2121
$Filters
2222
)
2323

24-
$ErrorActionPreference = 'Stop'
24+
2525
foreach ($filter in $Filters) {
2626
$res = @{
2727
Filter = $filter
@@ -31,7 +31,7 @@ function Get-ApplicableFilters {
3131
if (Test-WildcardFilter -Filter $filter) {
3232
$res['Strict'] = $true
3333
}
34-
}
34+
}
3535
elseif ($filter.Type -eq 'equalityOperator') {
3636
if (Test-EqualityFilter -Filter $filter) {
3737
$res['Strict'] = $true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
function Get-ResourceNameSuffix {
3+
param(
4+
[string]$ResourceName
5+
)
6+
if ($null -ne $ResourceName -and $ResourceName.Contains('/')) {
7+
$ResourceName = $ResourceName.Split("/")[-1]
8+
}
9+
return $ResourceName
10+
}

0 commit comments

Comments
 (0)