- Print
- Comment
- DarkLight
- PDF
Get Logic App Url in DevOps Pipeline
Article summary
Did you find this summary helpful?
Thank you for your feedback!
In this scenario I wanted to get the url for a Logic App in an Azure DevOps pipeline. I then want to set it as a variable so that I can access it to inject into an APIM policy.
The below script will create two variables called with the prefix of whatever you pass into the function and then put 2 variables in the output:
- (My Parameter Name)_BaseUrl
- (My Parameter Name)_Path
I have then injected this as a step in the devops pipeline and it will promote the properties so i can access them downstream in the pipeline.
Add-Type -AssemblyName System.Web
$resourceGroupName = '[My RG]'
function PromoteLogicAppPath([string] $logicAppName, [string] $devopsVariableName)
{
$logicApp = Get-AzLogicApp -ResourceGroupName $resourceGroupName -Name $logicAppName
$triggerUrl = Get-AzLogicAppTriggerCallbackUrl -Name $logicApp.Name -ResourceGroupName $resourceGroupName -TriggerName manual
$triggerUrlValue = $triggerUrl.Value
Write-Host 'Url for logic app - ' $logicAppName ' is = ' $triggerUrlValue
#Getting the local path gives us just the logic app is and query string. The base url is set via a common setting as all logic apps are on ise
$logicAppUri = [System.Uri]$triggerUrlValue
$logicAppUriLocalPath = $logicAppUri.PathAndQuery
$logicAppBaseUrl = $logicAppUri.GetLeftPart('Authority')
#Xml Encode the string for the APIM policy
$encodedUriPath = [System.Web.HttpUtility]::HtmlEncode($logicAppUriLocalPath)
Write-Host 'Encoded Uri Path:' $encodedUriPath
Write-Host 'Base Url:' $logicAppBaseUrl
#This will promote the variable as a DevOps pipeline variable
$baseUrlVariableName = $devopsVariableName + '_BaseUrl'
$pathUrlVariableName = $devopsVariableName + '_Path'
Write-Host "##vso[task.setvariable variable=$baseUrlVariableName]$($logicAppBaseUrl)"
Write-Host "##vso[task.setvariable variable=$pathUrlVariableName]$($encodedUriPath)"
}
PromoteLogicAppPath -logicAppName '[My Logic App]' -devopsVariableName '[My Variable]'
Was this article helpful?