Skip to content

Commit

Permalink
Merge pull request #44 from AsbjornNielsen/feature/addTenantId4AzContext
Browse files Browse the repository at this point in the history
add TenantId4AzContext parameter to allow service connections to Set-AzContext to several tenants
  • Loading branch information
JulianHayward committed Aug 30, 2023
2 parents bc82d93 + c99d7e6 commit d4d11c3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
Binary file modified pwsh/module/build/AzAPICall.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion pwsh/module/build/AzAPICall/AzAPICall.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AzAPICall.psm1'

# Version number of this module.
ModuleVersion = '1.1.75'
ModuleVersion = '1.1.76'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
13 changes: 11 additions & 2 deletions pwsh/module/build/AzAPICall/functions/AzAPICallFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ function getAzAPICallFunctions {
function getAzAPICallRuleSet {
return $function:AzAPICallErrorHandler.ToString()
}
function getAzAPICallVersion { return '1.1.75' }
function getAzAPICallVersion { return '1.1.76' }

function getJWTDetails {
<#
Expand Down Expand Up @@ -1797,6 +1797,10 @@ function initAzAPICall {
[string]
$SubscriptionId4AzContext,

[Parameter()]
[string]
$TenantId4AzContext,

[Parameter()]
[bool]
$SkipAzContextSubscriptionValidation = $false,
Expand Down Expand Up @@ -1874,7 +1878,12 @@ function initAzAPICall {

Logging -preventWriteOutput $true -logMessage " Setting Az context to SubscriptionId: '$SubscriptionId4AzContext'"
try {
$null = Set-AzContext -SubscriptionId $SubscriptionId4AzContext -ErrorAction Stop
if ($null -eq $TenantId4AzContext) {
$null = Set-AzContext -SubscriptionId $SubscriptionId4AzContext -ErrorAction Stop
}
else {
$null = Set-AzContext -SubscriptionId $SubscriptionId4AzContext -TenantId $TenantId4AzContext -ErrorAction Stop
}
}
catch {
Logging -preventWriteOutput $true -logMessage $_
Expand Down
2 changes: 1 addition & 1 deletion pwsh/module/dev/AzAPICall/AzAPICall.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'AzAPICall.psm1'

# Version number of this module.
ModuleVersion = '1.1.75'
ModuleVersion = '1.1.76'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
function getAzAPICallVersion { return '1.1.75' }
function getAzAPICallVersion { return '1.1.76' }
11 changes: 10 additions & 1 deletion pwsh/module/dev/AzAPICall/functions/initAzAPICall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
[string]
$SubscriptionId4AzContext,

[Parameter()]
[string]
$TenantId4AzContext,

[Parameter()]
[bool]
$SkipAzContextSubscriptionValidation = $false,
Expand Down Expand Up @@ -96,7 +100,12 @@

Logging -preventWriteOutput $true -logMessage " Setting Az context to SubscriptionId: '$SubscriptionId4AzContext'"
try {
$null = Set-AzContext -SubscriptionId $SubscriptionId4AzContext -ErrorAction Stop
if ($null -eq $TenantId4AzContext) {
$null = Set-AzContext -SubscriptionId $SubscriptionId4AzContext -ErrorAction Stop
}
else {
$null = Set-AzContext -SubscriptionId $SubscriptionId4AzContext -TenantId $TenantId4AzContext -ErrorAction Stop
}
}
catch {
Logging -preventWriteOutput $true -logMessage $_
Expand Down

0 comments on commit d4d11c3

Please sign in to comment.