Private/Invoke-AzWorkspaceManager.ps1
#requires -module @{ModuleName = 'Az.Accounts'; ModuleVersion = '2.10.0'} #requires -version 6.2 function Invoke-AzWorkspaceManager { [CmdletBinding()] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [string]$FunctionName ) <# .SYNOPSIS Get prerequisites and validate access to the Microsoft Azure API .DESCRIPTION This function is called by all functions to validate if the access token in still valid. .EXAMPLE Invoke-AzWorkspaceManager .NOTES NAME: Invoke-AzWorkspaceManager #> Write-Verbose "Function Name: $($FunctionName)" $azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile if ($azProfile.Contexts.Count -ne 0) { if ([string]::IsNullOrEmpty($script:accessToken)) { try { Get-AccessToken } catch { Write-Error -Exception $_.Exception.Message break } } elseif ($SessionVariables.ExpiresOn - [datetime]::UtcNow.AddMinutes(-5) -le 0) { # if token expires within 5 minutes, request a new access token try { Get-AccessToken } catch { Write-Error -Exception $_.Exception.Message break } } # Set the subscription from AzContext $SessionVariables.baseUri = "https://management.azure.com/subscriptions/$($SessionVariables.subscriptionId)" $script:authHeader = @{ 'Authorization' = 'Bearer ' + [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($($SessionVariables.AccessToken))) } } else { Write-Message -FunctionName $MyInvocation.MyCommand.Name "Run Connect-AzAccount to login" -Severity 'Error' break } } # SIG # Begin signature block # MIIbwQYJKoZIhvcNAQcCoIIbsjCCG64CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQURB5goQLLj0XGZZ+KKiELFRRE # /2ugghYrMIIDHjCCAgagAwIBAgIQYIvF2ca16Y1DENtprz1s/TANBgkqhkiG9w0B # AQsFADAnMSUwIwYDVQQDDBxQb3dlclNoZWxsIENvZGUgU2lnbmluZyBDZXJ0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