web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Azure Devops - ALM - R...
Power Apps
Answered

Azure Devops - ALM - Retrieve Environment URL from Service Connection

(0) ShareShare
ReportReport
Posted on by 28

Hi Everyone

 

Looking for some help in retrieving the Environment URL from a service connection, when using the 'Power Platform Set Connection Variables' task.

 

Currently I have the following in my yaml file:

 

 

task: PowerPlatformSetConnectionVariables@2
 displayName: 'Set Connection Variables'
 name: connectionVariables
 inputs:
 authenticationType: 'PowerPlatformSPN'
 PowerPlatformSPN: 'MyServiceConnectionName'

 

 

With this I am able to access the service connection's AppID/TenantID/Secret for use in my Powershell scripts with no issue, for example:

 

Add-PowerAppsAccount -TenantID '$(connectionVariables.BuildTools.TenantId)' -ApplicationId '$(connectionVariables.BuildTools.ApplicationId)' -ClientSecret '$(connectionVariables.BuildTools.ClientSecret)' -Endpoint "prod"

 

 

However, when accessing the variable connectionVariables.BuildTools.DataverseConnectionString it returns the following with the environment URL marked as undefined

 

AuthType=ClientSecret;url=undefined;ClientId=****...

 

  

By default it looks like the environment property on the 'Power Platform Set Connection Variables' task is set to $(BuildTools.EnvironmentUrl), which looking at the documentation is only populated on the pipeline when the 'Power Platform Create Environment' task is used (devops-build-tool-tasks#power-platform-create-environment )

 

So we've tried adding the Environment property onto the task, but still returns as undefined (hard coded example):

 

task: PowerPlatformSetConnectionVariables@2
 displayName: 'Set Connection Variables'
 name: connectionVariables
 inputs:
 authenticationType: 'PowerPlatformSPN'
 PowerPlatformSPN: 'MyServiceConnectionName'
 Environment: 'myenvironmenturl.crm.dynamics.com'

 

 

As a work around we can build the dataverse connection string in the Powershell script, but feels like this shouldn't be necessary given there's a variable on the pipeline for it.

 

Any insight much appreciated!

I have the same question (0)
  • Verified answer
    Dohsan Profile Picture
    28 on at

    Managed to find the fix/workaround for this. If you run a powershell task in your pipeline first, you can set the $(BuildTools.EnvironmentUrl)

     

    task: PowerShell@2
     displayName: "Set Service Connection Url"
     inputs:
     targetType: 'inline'
     script: |
     Write-Host "##vso[task.setvariable variable=BuildTools.EnvironmentUrl]${{'https://yourUrl.dynamics.com'}}"

     

    The 'Power Platform Set Connection Variables' then picks this up by default and correctly sets the url on BuildTools.DataverseConnectionString

  • smadep Profile Picture
    96 on at

    any chance to retrieve that env url (like Microsoft does it in WhoAmI task)

    smadep_0-1685435948616.png

    and use it tasks below? or set it like with the powershell task in recommended "solution" above?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 977

#2
Valantis Profile Picture

Valantis 664

#3
11manish Profile Picture

11manish 530

Last 30 days Overall leaderboard