Skip to content

Commit 71ad53b

Browse files
Merge pull request #52 from JulianHayward/users/kaiaschulz/v1.3.3
Users/kaiaschulz/v1.3.3
2 parents 226b6d2 + 371c6f2 commit 71ad53b

13 files changed

Lines changed: 2950 additions & 78 deletions

File tree

pwsh/module/build/AzAPICall.zip

179 Bytes
Binary file not shown.

pwsh/module/build/AzAPICall/AzAPICall.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'AzAPICall.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.3.2'
15+
ModuleVersion = '1.3.3'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

pwsh/module/build/AzAPICall/functions/AzAPICallFunctions.ps1

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,16 +1603,36 @@ function createBearerToken {
16031603
setBearerAccessToken -createdBearerToken $createdBearerToken -targetEndPoint $targetEndPoint -targetCluster $TargetCluster -AzAPICallConfiguration $AzAPICallConfiguration
16041604
}
16051605
else {
1606-
$tokenRequestEndPoint = ($AzApiCallConfiguration['azAPIEndpointUrls']).$targetEndPoint
1607-
$createdBearerToken = ([Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate($azContext.Account, $azContext.Environment, $azContext.Tenant.id.ToString(), $null, [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, $null, "$tokenRequestEndPoint")).AccessToken
1608-
setBearerAccessToken -createdBearerToken $createdBearerToken -targetEndPoint $targetEndPoint -AzAPICallConfiguration $AzAPICallConfiguration
1606+
try {
1607+
$tokenRequestEndPoint = ($AzApiCallConfiguration['azAPIEndpointUrls']).$targetEndPoint
1608+
}
1609+
catch {
1610+
Write-Warning 'dfc4ced5-695b-4b6f-8ec9-464c1d886322'
1611+
Throw $_
1612+
}
1613+
1614+
try {
1615+
$createdBearerToken = ([Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate($azContext.Account, $azContext.Environment, $azContext.Tenant.id.ToString(), $null, [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, $null, "$tokenRequestEndPoint")).AccessToken
1616+
}
1617+
catch {
1618+
Write-Warning '724378c1-37ef-42e2-9a84-16581ee48cf6'
1619+
Throw $_
1620+
}
1621+
1622+
try {
1623+
setBearerAccessToken -createdBearerToken $createdBearerToken -targetEndPoint $targetEndPoint -AzAPICallConfiguration $AzAPICallConfiguration
1624+
}
1625+
catch {
1626+
Write-Warning '37bd83b0-0b72-4cd5-ba59-d7b77d2a5d94'
1627+
Throw $_
1628+
}
16091629
}
16101630
}
16111631
catch {
16121632
if (($AzApiCallConfiguration['htParameters']).codeRunPlatform -eq 'GitHubActions') {
16131633
if (($AzApiCallConfiguration['htParameters']).GitHubActionsOIDC) {
16141634
if (($AzApiCallConfiguration['htParameters']).GitHubActionsOIDC -eq $true) {
1615-
if ($_ -like '*AADSTS700024*') {
1635+
if ($_ -like '*AADSTS700024*' -or $_ -like '*ClientAssertionCredential authentication failed*') {
16161636
Logging -logMessage " Running on '$(($AzApiCallConfiguration['htParameters']).codeRunPlatform)' OIDC: '$(($AzApiCallConfiguration['htParameters']).GitHubActionsOIDC)' - Getting Bearer Token from Login endpoint '$(($AzApiCallConfiguration['azAPIEndpointUrls']).Login)'"
16171637

16181638
$audience = 'api://AzureADTokenExchange'
@@ -1665,7 +1685,7 @@ function createBearerToken {
16651685
}
16661686
elseif (($AzApiCallConfiguration['htParameters']).codeRunPlatform -eq 'AzureDevOps') {
16671687
if (($AzApiCallConfiguration['htParameters']).accountType -eq 'ClientAssertion') {
1668-
if ($_ -like '*ClientAssertionCredential authentication failed*') {
1688+
if ($_ -like '*AADSTS700024*' -or $_ -like '*ClientAssertionCredential authentication failed*') {
16691689
Logging -logMessage " Running on '$(($AzApiCallConfiguration['htParameters']).codeRunPlatform)' OIDC: '$(($AzApiCallConfiguration['htParameters']).accountType)' - Getting Bearer Token from Login endpoint '$(($AzApiCallConfiguration['azAPIEndpointUrls']).Login)'"
16701690

16711691
if ([string]::IsNullOrWhiteSpace($env:SYSTEM_ACCESSTOKEN)) {
@@ -1728,6 +1748,10 @@ function createBearerToken {
17281748
Start-Sleep -Seconds 2
17291749
setBearerAccessToken -createdBearerToken $createdBearerToken -targetEndPoint $targetEndPoint -AzAPICallConfiguration $AzAPICallConfiguration
17301750
}
1751+
else {
1752+
Logging -logMessage " -ERROR: OIDC ADO - Not 'ClientAssertionCredential authentication failed'. `$_: $($_)"
1753+
$dumpErrorProcessingNewBearerToken = $true
1754+
}
17311755
}
17321756
}
17331757
else {
@@ -1799,7 +1823,7 @@ function getAzAPICallFunctions {
17991823
function getAzAPICallRuleSet {
18001824
return $function:AzAPICallErrorHandler.ToString()
18011825
}
1802-
function getAzAPICallVersion { return '1.3.2' }
1826+
function getAzAPICallVersion { return '1.3.3' }
18031827

18041828
function getJWTDetails {
18051829
<#
21.3 KB
Binary file not shown.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#
2+
# Module manifest for module 'AzAPICallBeta'
3+
#
4+
# Generated by: julianHayward
5+
#
6+
# Generated on: 2/27/2022
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = 'AzAPICallBeta.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '1.3.3.2'
16+
17+
# Supported PSEditions
18+
# CompatiblePSEditions = @()
19+
20+
# ID used to uniquely identify this module
21+
GUID = '16c6ca00-2411-4546-a483-6f7bb815670f'
22+
23+
# Author of this module
24+
Author = 'Julian Hayward, Kai Schulz'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'Unknown'
28+
29+
# Copyright statement for this module
30+
Copyright = '(c) All rights reserved.'
31+
32+
# Description of the functionality provided by this module
33+
Description = 'Azure API call handler for Microsoft Graph, Azure Resource Management, KeyVault, Log Analytics, Storage and ingest.monitor.azure.*. Visit aka.ms/AzAPICall'
34+
35+
# Minimum version of the PowerShell engine required by this module
36+
# PowerShellVersion = '7.0.3'
37+
38+
# Name of the PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
# DotNetFrameworkVersion = ''
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# ClrVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
# RequiredModules = @('Az.Accounts')
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
# RequiredAssemblies = @()
58+
59+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
60+
# ScriptsToProcess = @()
61+
62+
# Type files (.ps1xml) to be loaded when importing this module
63+
# TypesToProcess = @()
64+
65+
# Format files (.ps1xml) to be loaded when importing this module
66+
# FormatsToProcess = @()
67+
68+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
69+
# NestedModules = @()
70+
71+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
72+
FunctionsToExport = @('AzAPICall', 'initAzAPICall', 'getAzAPICallFunctions', 'getAzAPICallRuleSet', 'createBearerToken')
73+
74+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75+
CmdletsToExport = ''
76+
77+
# Variables to export from this module
78+
VariablesToExport = ''
79+
80+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
81+
AliasesToExport = ''
82+
83+
# DSC resources to export from this module
84+
# DscResourcesToExport = @()
85+
86+
# List of all modules packaged with this module
87+
# ModuleList = @()
88+
89+
# List of all files packaged with this module
90+
# FileList = @()
91+
92+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
93+
PrivateData = @{
94+
95+
PSData = @{
96+
97+
# Tags applied to this module. These help with module discovery in online galleries.
98+
# Tags = @()
99+
100+
# A URL to the license for this module.
101+
# LicenseUri = ''
102+
103+
# A URL to the main website for this project.
104+
ProjectUri = 'https://aka.ms/AzAPICall'
105+
106+
# A URL to an icon representing this module.
107+
# IconUri = ''
108+
109+
# ReleaseNotes of this module
110+
# ReleaseNotes = ''
111+
112+
# Prerelease string of this module
113+
# Prerelease = ''
114+
115+
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
116+
# RequireLicenseAcceptance = $false
117+
118+
# External dependent modules of this module
119+
# ExternalModuleDependencies = @()
120+
121+
} # End of PSData hashtable
122+
123+
} # End of PrivateData hashtable
124+
125+
# HelpInfo URI of this module
126+
# HelpInfoURI = ''
127+
128+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
129+
# DefaultCommandPrefix = ''
130+
131+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Get-ChildItem -Path $PSScriptRoot\functions | ForEach-Object -Process {
2+
. $PSItem.FullName
3+
}

0 commit comments

Comments
 (0)