Last active
April 26, 2025 10:16
-
-
Save ievgen-pavlenko/c86966e116534b489ae038a7fd334847 to your computer and use it in GitHub Desktop.
Managed Identity Demo Script for Azure Kudu Environment
This file contains hidden or 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