Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

Azure DevOps Reset Environment 2 errors

(1) ShareShare
ReportReport
Posted on by 26

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.

bpm_0-1648607062690.png

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.

bpm_1-1648607817056.png

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."

bpm_2-1648608018151.png

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.

  • dsal Profile Picture
    6 on at
    Re: Azure DevOps Reset Environment 2 errors

    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...

    Write-Host "##vso[task.setvariable variable=PowerPlatformCreateEnvironment.BuildTools.EnvironmentUrl;isoutput=true]"

     

    But it led to this error:

    ##[error]Unable to process command '##vso[task.setvariable variable=PowerPlatformCreateEnvironment.BuildTools.EnvironmentUrl;isoutput=true]' successfully. Please reference documentation (http://go.microsoft.com/fwlink/?LinkId=817296)
    ##[error]Overwriting readonly variable 'PowerPlatformCreateEnvironment.BuildTools.EnvironmentUrl' is not permitted. See https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/readonly-variables.md for details.
     
    Meaning, I think it's literally impossible to reset this variable.
     
    So I did something similar to you. Instead of a different job in the same pipeline, I just called the first pipeline to build and deploy an artifact, then the second pipeline to grab the artifact and deploy it to the next highest environment. It's kind of annoying, maybe I will try using one pipeline with separate jobs like you did, that sounds cleaner.
     
    I wish we had the capability to control which environments we work with after we call the Create Environment task, but, this workaround will work.
     
    Take care.
  • benny-moore Profile Picture
    26 on at
    Re: Azure DevOps Reset Environment 2 errors

    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? 

  • dsal Profile Picture
    6 on at
    Re: Azure DevOps Reset Environment 2 errors

    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?

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 81 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 53 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 48

Overall leaderboard