We're attempting to use the PowerPlatformResetEnvironment; however, we are finding two different errors within our workflow, depending on whether the Environment comes back without waiting or not.
Case 1) Reset Environment Task Wait for Environment attempts to poll:
In the case that the Reset Environment Task cannot find the environment at the end of the task, it attempts to poll the admin url for the environment to appear. If so, it immediately fails with:
##[error]Cannot bind argument to parameter 'InputObject' because it is null.
Investigating the task further - by enabling diagnostics - show that the error occurs inside the Microsoft.PowerApps.Administration.PowerShell cmdlet Reset-PowerAppEnvironment. Running this manually, we see that indeed this error does get thrown. But because errors aren't necessarily blocking in PowerShell, the command continues, and eventually returns the environment when it finally finds it. Reading between the lines, it appears the the ConvertTo-Json function is being called on the result of a Get-AdminPowerAppEnvironment call, and while polling, this command returns a null object. Hence the actual error.
However, Azure DevOps pipelines do block on an error (unless you explicitly tell it not to, more on that later). In which case, the task sees the error and causes the pipeline to stop prematurely.
Our resolution for this at the moment is to tell the task to continue on error, and then use a PowerShell task to redo the polling, this time without requiring the ConvertTo-Json on the null environment. This often works; however, sometimes the Reset Environment succeeds within the initial timespan. In this case, we get a very different error.
Case 2) Reset Environment Task Wait for Environment returns the environment on the first request
When the Reset Environment task completes, at the very end it sets 4 BuildTools variables. However it has a bug in it when setting the EnvironmentUrl variable, deleting the domain.
3/30/2022 12:47:52 AM | INFO | BuildTools.EnvironmentUrl : https://.crm6.dynamics.com/
Somehow, this Url has an empty domain.
Unfortunately, from what I've been able to gather, if this variable exists, other PowerPlatform tasks further down the pipeline attempt to use it. And hence when we attempt to Import our solution to the reset environment, it fails with
##[error]Cannot bind parameter 'EnvironmentUrl'. Cannot convert value "https://.crm6.dynamics.com/" to type "System.Uri". Error: "Invalid URI: The hostname could not be parsed."
I suspect a viable workaround here is to re-update this variable in our powershell code we have in between the steps. but I haven't gotten that to work yet either. It's remarkably difficult to test. as to whether the Reset Environment task succeeds or fails appears up to chance.
Hi @bpm I was able to output all environment variables to see the naming convention, which the documentation doesn't cover very well. This led me to run this line, which was recognized as the correct syntax and variable name...
But it led to this error:
Hi @dansal, I did and I didn't. Technically, you can use a script section with the
##vso[task.setvariable variable]value
syntax, but I found this didn't always work with the URL. I couldn't figure out how to set it to null, so that other tasks could use their defaults...
But then it occurred to me that variables were scoped to the jobs. You could reuse a variable from another job, but you have to call it by referring to the job that it was created in. So my eventual workaround for my Case 2 problem above was to have the reset environment task in one job, and the import environment task in another.
Since I didn't really care about the output variables from the first job—each PowerPlatform task used the same service connection for these values—by splitting the jobs it would form a new scope and the new environment variables set by the first wouldn't interfere with the second.
Perhaps this would work with your issue too?
Hi @bpm ,I am having the same issue with BuildTools.EnvironmentUrl. It's set when I create an environment in the YAML pipeline, but I want to delete the environment and work with another environment in the same pipeline. Did you figure out how to reset this variable to another environment or force it blank so the tasks run using the environment URL from the service connection?
WarrenBelz
81
Most Valuable Professional
mmbr1606
53
Super User 2025 Season 1
stampcoin
48