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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

automate start and stop environments through Microsoft Dynamics Lifecycle Services (LCS)

(0) ShareShare
ReportReport
Posted on by 10

Is there a way to automate the starting and stopping of environments through Microsoft Dynamics Lifecycle Services (LCS). I know I can turn off and back on the VMs from the Azure console, but it does not reflect the stopping and starting of the VMs in the LCS URL.

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
  • skyjacker Profile Picture
    10 on at

    I dont know how to do API calls to the LCS environment.

    For the D365FO tool, I keep getting this error message,

    [08:56:54][<Unknown>] Unable to locate the %ServiceDrive% environment variable. It could indicate that the machine is either not configured with D365FO or that you have domain joined a local Ti

    er1. We have defaulted to c:\

    [08:56:54][<Unknown>] This message will show every time you load the module. If you want to silence this message, please add the ServiceDrive environment variable by executing this command (rem

    ember to restart the console afterwards):

    [Environment]::SetEnvironmentVariable("ServiceDrive", "C:", "Machine")

    [08:56:55][Invoke-Authorization] Something went wrong while working against Azure Active Directory (AAD) | The remote server returned an error: (400) Bad Request.

    WARNING: [08:56:55][Invoke-Authorization] Stopping because of errors

  • nmaenpaa Profile Picture
    101,160 Moderator on at

    And what exactly did you do before you got this error message? What command did you run? Did you look in d365fo.tools documentation?

  • skyjacker Profile Picture
    10 on at

    I ran this command:

    Get-D365LcsApiToken -ClientId “cdbb2d84-bf0b-406f-9195-xxxxx” -Username “xxxxx” -Password “xxxxx*” -LcsApiUri “lcsapi.lcs.dynamics.com” | Set-D365LcsApiConfig -ProjectId 136xxxx

  • Motz Jensen Profile Picture
    190 on at

    Without knowing all the details, here is a link, that the entire community is using as reference for these things: ariste.info/.../

    It is a wall of text, but you should be able to see how he made sure the Registered Application in the Azure AD was created correctly. Which brings me to some of the things that you should look into:

    Do you already use the Registered Application for any of the official tasks in Azure DevOps? This is to tell us if you have configured the basis inside Azure AD, or we have to ensure that you have all the details in place.

    Did you grant the "Dynamics Lifecycle services" API permission for the Registered Application?

    Did you "Allow public client flows" under the Authentication inside Azure AD?

    Are you sure that the LCS instance that you're assigned to is in fact the US based and not one of the 8 other available instances?

    Try it one more time, the command that you shared. But right after it fails, write:

    $error

    and share the output from that.

  • skyjacker Profile Picture
    10 on at

    Do you already use the Registered Application for any of the official tasks in Azure DevOps? This is to tell us if you have configured the basis inside Azure AD, or we have to ensure that you have all the details in place. -- No

    Did you grant the "Dynamics Lifecycle services" API permission for the Registered Application? -- Yea

    Did you "Allow public client flows" under the Authentication inside Azure AD? -- Yes

    Are you sure that the LCS instance that you're assigned to is in fact the US based and not one of the 8 other available instances? -- Now do I find which instance I am assigned to?

    Try it one more time, the command that you shared. But right after it fails, write:

    $error

    and share the output from that. -- [15:40:44][Invoke-Authorization] Something went wrong while working against Azure Active Directory (AAD) | The remote server returned an error: (400) Bad Request.

    WARNING: [15:40:44][Invoke-Authorization] Stopping because of errors

  • Suggested answer
    Dieter Profile Picture
    127 on at

    I've experienced the same error when I was trying to execute a data restore from a D365 F&O tier 5 to a tier 2 environment.

    "[Invoke-Authorization] Something went wrong while working against Azure Active Directory (AAD) | The remote server returned an error: (400) Bad Request."

    The issue here was the password. It included a $ sign, which made the script think it was a variable and for reason left it out of the password value.

    LCS-_2D00_-AAD-connect-password-issue-_2D00_-Bad-Request.png

    Also keep this in mind when entering the arguments in a DevOps pipeline. If the password has a $ sign in it, don't use double quotes.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans