Calling the LCS API in your Azure DevOps pipeline to start and stop environments

Any easy cost saving mechanism for Dynamics 365 for Finance and Operations projects is to implement start and stop of cloud self hosted environments in LCS. 

Many projects implement this by directly through Azure Portal. With this approach the deployment status of the environment isn't reflected correct in LCS. There is a risk that the environment is stopped when it's in a state which could cause a problem if the VM is stopped. For example, in the middle of a deployment. 

An easy way to start/stop environments is to use the LCS API for environment status with the start/stop.

To implement this use the code snippet below.

1. Create a pipeline in your DevOps with a PowerShell task
2. Choose inline script
3. Copy in the script, replace the credential variable values with your details. 
3. Setup a schedule for your pipeline to run the script automatically. 



This work was based on the original work of Ariste

Comments

Popular posts from this blog

How to disable auto enabled flight key using KillSwitch

Technical intro to Feature management in D365FO

Continuous integration and deployment Power platform FinOps tweaking