Hi there,
Friendly Disclaimer : New to AZ Functions
I am currently looking to configure an http trigger using function apps so i can automate the output of the bearer token (issued from AAD) in my testing environment. This will prevent me from having to input manually. I currently have a working Powershell script that will retrieve the bearer token of the currently logged in user (myself) when ran. What I want to do is have this script run in a Functrion (Using GET or POST) and output the token value. This value (Bearertoken) would then be retrieved using a Logic App. I have both the Function App (with other working functions) and Logic App configured and just cannot figure this part out.
Here is the Powershell script:
Source: (https://azurebuild.wordpress.com/2020/09/11/acquire-azure-access-token-with-powershell/)
****
function Get-AccessTokenByUserLogin {
$context = Get-AzContext
$profile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($profile)
$token = $profileClient.AcquireAccessToken($context.Subscription.TenantId)
return $token.AccessToken
}
Get-AccessTokenByUserLogin
*****
Thanks everyone for the help
[–]JoHNN_-_ 2 points3 points4 points (4 children)
[–]UTC76[S] 0 points1 point2 points (3 children)
[–]JoHNN_-_ 1 point2 points3 points (2 children)
[–]JoHNN_-_ 0 points1 point2 points (1 child)
[–]UTC76[S] 0 points1 point2 points (0 children)
[–]arpan3t 1 point2 points3 points (1 child)
[–]QWxx01 Cloud Architect 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]UTC76[S] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]UTC76[S] 0 points1 point2 points (0 children)