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!