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

Notifications

Announcements

Community site session details

Community site session details

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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard