Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit b32e528

Browse files
authored
Updated Get-AzSubscriptionId to get the subscription id using latest version of AzureRM.Profile. (#274)
* Updated Get-AzSubscriptionId to get the subscription id using latest version of AzureRM.Profile.
1 parent 5253fb4 commit b32e528

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

PSSwagger/PSSwagger.Azure.Helpers/PSSwagger.Azure.Helpers.psm1

+9-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,15 @@ function Get-AzSubscriptionId
4747
[CmdletBinding()]
4848
param()
4949

50-
$AzureContext = & "$moduleName\Get-AzureRmContext" -ErrorAction Stop
51-
$AzureContext.Subscription.SubscriptionId
50+
$AzureContext = & "$moduleName\Get-AzureRmContext" -ErrorAction Stop
51+
if(Get-Member -InputObject $AzureContext.Subscription -Name SubscriptionId)
52+
{
53+
return $AzureContext.Subscription.SubscriptionId
54+
}
55+
else
56+
{
57+
return $AzureContext.Subscription.Id
58+
}
5259
}
5360

5461
function Get-AzResourceManagerUrl

Tests/run-tests.ps1

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ $autoRestInstallPath = Split-Path -Path $autoRestModule.Source
9999
$executeTestsCommand += ";`$env:Path+=`";$autoRestInstallPath\tools`""
100100

101101
# AzureRM.Profile requirement
102-
$azureRmProfile = Get-Package AzureRM.Profile -ErrorAction Ignore
102+
$azureRmProfile = Get-Package -Name AzureRM.Profile -Provider PowerShellGet -ErrorAction Ignore
103103
if (-not $azureRmProfile) {
104-
if (-not (Get-PackageSource PSGallery -ErrorAction Ignore)) {
105-
Register-PackageSource PSGallery -ProviderName PowerShellGet
104+
if (-not (Get-PackageSource -Name PSGallery -ErrorAction Ignore)) {
105+
Register-PackageSource -Name PSGallery -ProviderName PowerShellGet
106106
}
107107

108-
$azureRmProfile = Install-Package AzureRM.Profile -Source PSGallery -RequiredVersion 2.8.0 -Force | Where-Object { $_.Name -eq 'AzureRM.Profile' }
108+
$azureRmProfile = Install-Package -Name AzureRM.Profile -Provider PowerShellGet -Source PSGallery -Force | Where-Object { $_.Name -eq 'AzureRM.Profile' }
109109
}
110110

111111
$powershellFolder = $null

0 commit comments

Comments
 (0)