Created
November 22, 2022 14:02
-
-
Save ievgen-pavlenko/c86966e116534b489ae038a7fd334847 to your computer and use it in GitHub Desktop.
Get access token from KuDu shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#User Assigned Managed Identity | |
$ProgressPreference = "SilentlyContinue" | |
$clientId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' | |
$headers=@{"X-IDENTITY-HEADER"=$env:IDENTITY_HEADER} | |
$resourceUri = ‘https://management.azure.com/' | |
$uri = "$($env:IDENTITY_ENDPOINT)?api-version=2019-08-01&client_id=$clientId&resource=$resourceUri" | |
$response = Invoke-WebRequest -UseBasicParsing -Uri $uri -Headers $headers | |
$content = $response.Content | ConvertFrom-Json | |
$content.access_token | |
#System Assigned Managed Identity | |
$ProgressPreference = "SilentlyContinue" | |
$headers=@{"X-IDENTITY-HEADER"=$env:IDENTITY_HEADER} | |
$resourceUri = 'https://management.azure.com/' | |
$uri = "$($env:IDENTITY_ENDPOINT)?api-version=2019-08-01&resource=$resourceUri" | |
$response = Invoke-WebRequest -UseBasicParsing -Uri $uri -Headers $headers | |
$content = $response.Content | ConvertFrom-Json | |
$content.access_token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment