Skip to content

Commit 1fc95aa

Browse files
author
Hovsep
committed
Merge pull request #1678 from hovsepm/dev
[#111731500] Updated AzureRm module to include major versions for each package
2 parents 3fade8b + f1144eb commit 1fc95aa

File tree

3 files changed

+93
-114
lines changed

3 files changed

+93
-114
lines changed

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ protected static void InitializeDataCollectionProfile()
9999
{
100100
if (string.Equals(value, bool.FalseString, StringComparison.OrdinalIgnoreCase))
101101
{
102-
// Disable data collection only if it is explictly set to 'false'.
102+
// Disable data collection only if it is explicitly set to 'false'.
103103
_dataCollectionProfile = new AzurePSDataCollectionProfile(true);
104104
}
105105
else if (string.Equals(value, bool.TrueString, StringComparison.OrdinalIgnoreCase))
106106
{
107-
// Enable data collection only if it is explictly set to 'true'.
107+
// Enable data collection only if it is explicitly set to 'true'.
108108
_dataCollectionProfile = new AzurePSDataCollectionProfile(false);
109109
}
110110
}

tools/AzureRM/AzureRM.psm1

Lines changed: 67 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
1-
$AzureMajorVersion = "1"
2-
3-
$AzureRMModules = @(
4-
"AzureRM.ApiManagement",
5-
"AzureRM.Automation",
6-
"AzureRM.Backup",
7-
"AzureRM.Batch",
8-
"AzureRM.Compute",
9-
"AzureRM.DataFactories",
10-
"AzureRM.DataLakeAnalytics",
11-
"AzureRM.DataLakeStore",
12-
"AzureRM.Dns",
13-
"AzureRM.HDInsight",
14-
"AzureRM.Insights",
15-
"AzureRM.KeyVault",
16-
"AzureRM.Network",
17-
"AzureRM.NotificationHubs",
18-
"AzureRM.OperationalInsights",
19-
"AzureRM.RecoveryServices",
20-
"AzureRM.RedisCache",
21-
"AzureRM.Resources",
22-
"AzureRM.SiteRecovery",
23-
"AzureRM.Sql",
24-
"AzureRM.Storage",
25-
"AzureRM.StreamAnalytics",
26-
"AzureRM.Tags",
27-
"AzureRM.TrafficManager",
28-
"AzureRM.UsageAggregates",
29-
"AzureRM.Websites"
30-
)
1+
$AzureRMDependencies = @{
2+
"Azure.Storage" = "1.0.3";
3+
"AzureRM.Profile" = "1.0.3";
4+
}
5+
6+
$AzureRMModules = @{
7+
"AzureRM.ApiManagement" = "1.0.3";
8+
"AzureRM.Automation" = "1.0.3";
9+
"AzureRM.Backup" = "1.0.3";
10+
"AzureRM.Batch" = "1.0.3";
11+
"AzureRM.Compute" = "1.2.1";
12+
"AzureRM.DataFactories" = "1.0.3";
13+
"AzureRM.DataLakeAnalytics" = "1.0.3";
14+
"AzureRM.DataLakeStore" = "1.0.3";
15+
"AzureRM.Dns" = "1.0.3";
16+
"AzureRM.HDInsight" = "1.0.4";
17+
"AzureRM.Insights" = "1.0.3";
18+
"AzureRM.KeyVault" = "1.1.2";
19+
"AzureRM.Network" = "1.0.3";
20+
"AzureRM.NotificationHubs" = "1.0.3";
21+
"AzureRM.OperationalInsights" = "1.0.3";
22+
"AzureRM.RecoveryServices" = "1.0.4";
23+
"AzureRM.RedisCache" = "1.1.1";
24+
"AzureRM.Resources" = "1.0.3";
25+
"AzureRM.SiteRecovery" = "1.1.2";
26+
"AzureRM.Sql" = "1.0.3";
27+
"AzureRM.Storage" = "1.0.3";
28+
"AzureRM.StreamAnalytics" = "1.0.3";
29+
"AzureRM.Tags" = "1.0.3";
30+
"AzureRM.TrafficManager" = "1.0.3";
31+
"AzureRM.UsageAggregates" = "1.0.3";
32+
"AzureRM.Websites" = "1.0.3";
33+
}
3134

3235
function Test-AdminRights([string]$Scope)
3336
{
@@ -64,10 +67,10 @@ function CheckIncompatibleVersion([bool]$Force)
6467
}
6568
}
6669

67-
function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[string]$Repository,[string]$Scope,[switch]$Force)
70+
function Install-ModuleWithVersionCheck([string]$Name,[string]$MinimumVersion,[string]$Repository,[string]$Scope,[switch]$Force)
6871
{
69-
$_MinVer = "$MajorVersion.0.0.0"
70-
$_MaxVer = "$MajorVersion.9999.9999.9999"
72+
$_MinVer = $MinimumVersion
73+
$_MaxVer = "$($_MinVer.Split(".")[0]).9999.9999.9999"
7174
$script:InstallCounter ++
7275
try {
7376
$_ExistingModule = Get-Module -ListAvailable -Name $Name
@@ -82,7 +85,7 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion,[str
8285
Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -ErrorAction Stop
8386
}
8487
$v = (Get-InstalledModule -Name $Name -ErrorAction Ignore)[0].Version.ToString()
85-
Write-Output "$Name $v $_ModuleAction [$script:InstallCounter/$($AzureRMModules.Count + 2)]..."
88+
Write-Output "$Name $v $_ModuleAction [$script:InstallCounter/$($AzureRMModules.Count + $AzureRMDependencies.Count)]..."
8689
} catch {
8790
Write-Warning "Skipping $Name package..."
8891
Write-Warning $_
@@ -114,7 +117,7 @@ function Update-AzureRM
114117
param(
115118
[Parameter(Position=0, Mandatory = $false)]
116119
[string]
117-
$MajorVersion = $AzureMajorVersion,
120+
$MajorVersion,
118121
[Parameter(Position=1, Mandatory = $false)]
119122
[string]
120123
$Repository = "PSGallery",
@@ -137,12 +140,17 @@ function Update-AzureRM
137140
{
138141
Set-PSRepository -Name $Repository -InstallationPolicy Trusted
139142

140-
Install-ModuleWithVersionCheck "AzureRM.Profile" $MajorVersion $Repository $Scope -Force:$force
141-
Install-ModuleWithVersionCheck "Azure.Storage" $MajorVersion $Repository $Scope -Force:$force
143+
# Update Profile and Storage
144+
Install-ModuleWithVersionCheck "AzureRM.Profile" $AzureRMDependencies["AzureRM.Profile"] $Repository $Scope -Force:$force
145+
Install-ModuleWithVersionCheck "Azure.Storage" $AzureRMDependencies["Azure.Storage"] $Repository $Scope -Force:$force
142146

143147
# Start new job
144-
$AzureRMModules | ForEach {
145-
Install-ModuleWithVersionCheck $_ $MajorVersion $Repository $Scope -Force:$force
148+
$AzureRMModules.Keys | ForEach {
149+
$_MinVer = $MajorVersion
150+
if(!$MajorVersion) {
151+
$_MinVer = $AzureRMModules[$_]
152+
}
153+
Install-ModuleWithVersionCheck $_ $_MinVer $Repository $Scope -Force:$force
146154
}
147155
} finally {
148156
# Clean up
@@ -165,14 +173,17 @@ function Import-AzureRM
165173
param(
166174
[Parameter(Position=0, Mandatory = $false)]
167175
[string]
168-
$MajorVersion = $AzureMajorVersion)
176+
$MajorVersion )
169177
Write-Output "Importing AzureRM modules."
170178

171-
$_MinVer = "$MajorVersion.0.0.0"
172-
$_MaxVer = "$MajorVersion.9999.9999.9999"
173-
174-
$AzureRMModules | ForEach {
179+
$AzureRMModules.Keys | ForEach {
175180
$moduleName = $_
181+
$_MinVer = $MajorVersion
182+
if(!MajorVersion ) {
183+
$_MinVer = $AzureRMModules[$_]
184+
}
185+
$_MaxVer = "$($_MinVer.Split(".")[0]).9999.9999.9999"
186+
176187
$_MatchedModule = Get-InstalledModule -Name $moduleName -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -ErrorAction Ignore | where {$_.Name -eq $moduleName}
177188
if ($_MatchedModule -ne $null) {
178189
try {
@@ -186,10 +197,10 @@ function Import-AzureRM
186197
}
187198
}
188199

189-
function Uninstall-ModuleWithVersionCheck([string]$Name,[string]$MajorVersion)
200+
function Uninstall-ModuleWithVersionCheck([string]$Name,[string]$MinVersion)
190201
{
191-
$_MinVer = "$MajorVersion.0.0.0"
192-
$_MaxVer = "$MajorVersion.9999.9999.9999"
202+
$_MinVer = $MinVersion
203+
$_MaxVer = "$($_MinVer.Split(".")[0]).9999.9999.9999"
193204
# This is a workaround for a bug in PowerShellGet that uses "start with" matching for module name
194205
$_MatchedModule = Get-InstalledModule -Name $Name -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -ErrorAction Ignore | where {$_.Name -eq $Name}
195206
if ($_MatchedModule -ne $null) {
@@ -226,19 +237,23 @@ function Uninstall-AzureRM
226237
param(
227238
[Parameter(Position=0, Mandatory = $false)]
228239
[string]
229-
$MajorVersion = $AzureMajorVersion)
240+
$MinVersion)
230241

231242
Test-AdminRights "AllUsers"
232243

233244
Write-Output "Uninstalling AzureRM modules."
234245

235-
$AzureRMModules | ForEach {
246+
$AzureRMModules.Keys | ForEach {
236247
$moduleName = $_
237-
Uninstall-ModuleWithVersionCheck $_ $MajorVersion
248+
$_MinVer = $MinVersion
249+
if(!$MinVersion) {
250+
$_MinVer = $AzureRMModules[$_]
251+
}
252+
Uninstall-ModuleWithVersionCheck $_ $_MinVer
238253
}
239254

240-
Uninstall-ModuleWithVersionCheck "Azure.Storage" $MajorVersion
241-
Uninstall-ModuleWithVersionCheck "AzureRM.Profile" $MajorVersion
255+
Uninstall-ModuleWithVersionCheck "Azure.Storage" $AzureRMDependencies["Azure.Storage"]
256+
Uninstall-ModuleWithVersionCheck "AzureRM.Profile" $AzureRMDependencies["AzureRM.Profile"]
242257
}
243258

244259
New-Alias -Name Install-AzureRM -Value Update-AzureRM

tools/AzureRM/AzureRM.psm1-help.xml

Lines changed: 24 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
33
<!--Generated by PS Cmdlet Help Editor-->
44
<command:details>
5-
<command:name>Import-ModuleWithVersionCheck</command:name>
5+
<command:name>Install-ModuleWithVersionCheck</command:name>
66
<maml:description>
77
<maml:para />
88
</maml:description>
99
<maml:copyright>
1010
<maml:para />
1111
</maml:copyright>
12-
<command:verb>Import</command:verb>
12+
<command:verb>Install</command:verb>
1313
<command:noun>ModuleWithVersionCheck</command:noun>
1414
<dev:version />
1515
</command:details>
@@ -18,7 +18,7 @@
1818
</maml:description>
1919
<command:syntax>
2020
<command:syntaxItem>
21-
<maml:name>Import-ModuleWithVersionCheck</maml:name>
21+
<maml:name>Install-ModuleWithVersionCheck</maml:name>
2222
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0">
2323
<maml:name>Name</maml:name>
2424
<maml:description>
@@ -107,7 +107,7 @@
107107
<maml:description/>
108108
</dev:type>
109109
<maml:description>
110-
<maml:para />
110+
<maml:para />
111111
</maml:description>
112112
</command:inputType>
113113
</command:inputTypes>
@@ -119,7 +119,7 @@
119119
<maml:description/>
120120
</dev:type>
121121
<maml:description>
122-
<maml:para />
122+
<maml:para />
123123
</maml:description>
124124
</command:returnValue>
125125
</command:returnValues>
@@ -181,31 +181,7 @@
181181
</command:syntax>
182182
<command:parameters>
183183
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0">
184-
<maml:name>Repository</maml:name>
185-
<maml:description>
186-
<maml:para />
187-
</maml:description>
188-
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
189-
<dev:type>
190-
<maml:name>String</maml:name>
191-
<maml:uri/>
192-
</dev:type>
193-
<dev:defaultValue></dev:defaultValue>
194-
</command:parameter>
195-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
196-
<maml:name>InformationAction</maml:name>
197-
<maml:description>
198-
<maml:para />
199-
</maml:description>
200-
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
201-
<dev:type>
202-
<maml:name>ActionPreference</maml:name>
203-
<maml:uri/>
204-
</dev:type>
205-
<dev:defaultValue></dev:defaultValue>
206-
</command:parameter>
207-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
208-
<maml:name>InformationVariable</maml:name>
184+
<maml:name>MinVersion</maml:name>
209185
<maml:description>
210186
<maml:para />
211187
</maml:description>
@@ -225,7 +201,7 @@
225201
<maml:description/>
226202
</dev:type>
227203
<maml:description>
228-
<maml:para />
204+
<maml:para />
229205
</maml:description>
230206
</command:inputType>
231207
</command:inputTypes>
@@ -237,7 +213,7 @@
237213
<maml:description/>
238214
</dev:type>
239215
<maml:description>
240-
<maml:para />
216+
<maml:para />
241217
</maml:description>
242218
</command:returnValue>
243219
</command:returnValues>
@@ -305,7 +281,19 @@
305281
</command:syntaxItem>
306282
</command:syntax>
307283
<command:parameters>
308-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0">
284+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="0">
285+
<maml:name>MajorVersion</maml:name>
286+
<maml:description>
287+
<maml:para>Minimum major version for the update.</maml:para>
288+
</maml:description>
289+
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
290+
<dev:type>
291+
<maml:name>String</maml:name>
292+
<maml:uri/>
293+
</dev:type>
294+
<dev:defaultValue></dev:defaultValue>
295+
</command:parameter>
296+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1">
309297
<maml:name>Repository</maml:name>
310298
<maml:description>
311299
<maml:para>Limit the search for &quot;AzureRM&quot; cmdlets in a specific repository.</maml:para>
@@ -317,7 +305,7 @@
317305
</dev:type>
318306
<dev:defaultValue></dev:defaultValue>
319307
</command:parameter>
320-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="1">
308+
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="2">
321309
<maml:name>Scope</maml:name>
322310
<maml:description>
323311
<maml:para>Specifies the parameter scope.</maml:para>
@@ -329,30 +317,6 @@
329317
</dev:type>
330318
<dev:defaultValue></dev:defaultValue>
331319
</command:parameter>
332-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
333-
<maml:name>InformationAction</maml:name>
334-
<maml:description>
335-
<maml:para />
336-
</maml:description>
337-
<command:parameterValue required="true" variableLength="false">ActionPreference</command:parameterValue>
338-
<dev:type>
339-
<maml:name>ActionPreference</maml:name>
340-
<maml:uri/>
341-
</dev:type>
342-
<dev:defaultValue></dev:defaultValue>
343-
</command:parameter>
344-
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
345-
<maml:name>InformationVariable</maml:name>
346-
<maml:description>
347-
<maml:para />
348-
</maml:description>
349-
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
350-
<dev:type>
351-
<maml:name>String</maml:name>
352-
<maml:uri/>
353-
</dev:type>
354-
<dev:defaultValue></dev:defaultValue>
355-
</command:parameter>
356320
</command:parameters>
357321
<command:inputTypes>
358322
<command:inputType>
@@ -394,14 +358,14 @@
394358
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
395359
<!--Generated by PS Cmdlet Help Editor-->
396360
<command:details>
397-
<command:name>Validate-AdminRights</command:name>
361+
<command:name>Test-AdminRights</command:name>
398362
<maml:description>
399363
<maml:para>Validate this session is running as Administrator</maml:para>
400364
</maml:description>
401365
<maml:copyright>
402366
<maml:para />
403367
</maml:copyright>
404-
<command:verb>Validate</command:verb>
368+
<command:verb>Test</command:verb>
405369
<command:noun>AdminRights</command:noun>
406370
<dev:version />
407371
</command:details>

0 commit comments

Comments
 (0)