Forum Discussion
Jan 02, 2023
Interact with Website through Azure App Proxy with Powershell
Greetings, recently we have migrated a locally hosted website to Azure. That website, let's call it "KM" is only used for displaying information, which are queried from a MS SQL Database. KM move...
- Jan 05, 2023
If anyone finds this later on, i found a solution myself:
Main help was this documentation Accessing API through AppProxy
You need an App Registration and then request a token through that AppReg using the MSAL.
# Preconfiguration: # https://learn.microsoft.com/en-us/azure/active-directory/app-proxy/application-proxy-secure-api-access $AppRegClientID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" $TenantID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" Import-module MSAL.ps $mytoken = Get-MsalToken -ClientId $AppRegClientID -TenantId $TenantID -scope https://km.<domain>/user_impersonation $accessToken = @{Authorization = "Bearer $($mytoken.AccessToken)" } $request = Invoke-WebRequest -Method Get -Headers $accessToken -Uri https://km.<domain>
Jan 05, 2023
If anyone finds this later on, i found a solution myself:
Main help was this documentation Accessing API through AppProxy
You need an App Registration and then request a token through that AppReg using the MSAL.
# Preconfiguration:
# https://learn.microsoft.com/en-us/azure/active-directory/app-proxy/application-proxy-secure-api-access
$AppRegClientID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
$TenantID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Import-module MSAL.ps
$mytoken = Get-MsalToken -ClientId $AppRegClientID -TenantId $TenantID -scope https://km.<domain>/user_impersonation
$accessToken = @{Authorization = "Bearer $($mytoken.AccessToken)" }
$request = Invoke-WebRequest -Method Get -Headers $accessToken -Uri https://km.<domain>