Thumbnail image

Release Your Dynamics 365 for Finance and Operation Packages to LCS with Azure DevOps Pipelines [ENG]

!
Warning: This post is over 365 days old. The information may be out of date.

Table of Contents

The first automation task to close the continuous integration cycle in Dynamics 365 for Finance and Operations with Azure DevOps pipelines was released recently as described on the official announcement.

These are some high-level instructions to set it up while the official documentation is released:

Prerequisites

To keep things simple, these prerequisites should be prepared before starting this process:

Also prepare:

  • A user with enough permissions in your LCS project (you must know the user and password). Consider using a service account whose password does not expire and not using 2FA.
  • Access to the Azure Active Directory administration for your organization, with enough permissions to register a new Application in AAD (this needs to be done only once), as explained on the next step.

1. Register an Application in AAD (New version)

In order to authorize Azure DevOps Pipelines to connect to the new Lifecycle Services (LCS) API, an application must be created in the organization’s Azure Active Directory (Elevated permissions are required for this operation).

  • Go to portal.azure.com and search or navigate to Azure Active Directory.
  • Navigate to the sub-menu App registrations > New registration
  • Give it a descriptive name of your choice and select Accounts in this organizational directory only (yourdomain only - Single tenant)
  • On Redirect URI (optional), write https://localhost
  • Click Register
Azure Active Directory - Register an application
  • Click API permisions > Add a permission
  • Search “Dynamics(usually easier on the “APIs my organization uses” tab) and select Dynamics Lifecycle services
  • Click and select user_impersonation permission and Add permissions button.
  • Click Grant admin constent for yourdomain, answer Yes and wait for confirmation; Status should change to Granted for yourdomain
Azure API permissions - Add a permission
  • Go to Authentication menu and be sure Treat application as a public client is set to Yes (this replaces the old “Native Application” registration process)
  • Click Save and the newly created application is ready..
Native Application - Treat application as public client

More information

2. Create the Release Pipeline in Azure DevOps

release pipeline will be used to connect the Build output with the Asset Library in LCS. New build packages will be uploaded to LCS automatically through this pipeline.

  • Login to your organization’s Azure DevOps project and navigate to Pipelines > Releases.
  • Click New release pipeline (this is the only available option if you don’t have any pipeline already created).
  • Select a template: Empty job.
  • Click on Artifacts > +Add an artifact (this will connect this release pipeline with a Build).
  • Select Build as Source type, and select your Project, Source and Default version (use Latest if this release should be executed automatically) and finally click Add.
  • If you want this release to be executed immediately after the build ends (so the build output is uploaded to LCS each time) enable the Continuous Integration flag by using the small icon highlighted in blue on the next screenshot (C.I.).
  • Click on the Stage 1 or Tasks link to open the details.
  • Select the Agent job node and validate that Agent pool parameter is set to Hosted VS2017.
  • Click the [+] button on the Agent Job node.
  • Search for the Dynamics Lifecycle Services (LCS) Asset Upload task (it should be already installed or it can be installed at this point, click Refresh if the task does not appear in the list) and finally click Add to add the task to the pipeline.
  • Fill these properties on the newly created Task like:
    • LCS Connection: Select a connection or click [+New] if this is the first time:

      • Connection name: use a descriptive name (in case you have multiple LCS projects).
      • Authentication Endpoint: let the default value.
      • Lifecycle Services API Endpoint:
        • If your LCS URL is like: https://lcs.dynamics.com, use the value https://lcsapi.lcs.dynamics.com (by default, and most commonly used).
        • If your LCS URL is like: https://eu.lcs.dynamics.com (note the 'eu' part) use the value https://lcsapi.eu.lcs.dynamics.com.
      • Username and Password: use the credentials (fully qualified user name including domain and password) from a user with enough permissions to upload files to your LCS project.
      • Application (Client) ID: use the previously created AAD application’s guid. You should have it saved from the first step.
    • LCS Project Id: this is the numeric value included in your LCS project URL.

      • Example: if your URL is like https://lcs.dynamics.com/V2/ProjectOverview/1234567, your Project Id is 1234567.
    • Type of asset: Software Deployable Package.

    • File to upload: click the […] button to select the AXDeployableRuntime_XXX_YYY.zip file in your build artifact’s Packages folder.

      • This is the default configuration, you might want to select a different file if your build definition is customized, but it must be a deployable package and its name should include the build number.
      • Back in the Pipeline properties, replace the build number with the variable $(Build.BuildNumber)
        • Example, for the filename: $(System.DefaultWorkingDirectory)/Unified Operations platform - Build Main/Packages/AXDeployableRuntime_7.0.5126.35370_2019.1.29.1.zip, use the property value: $(System.DefaultWorkingDirectory)/Unified Operations platform - Build Main/Packages/AXDeployableRuntime_7.0.5126.35370_$(Build.BuildNumber).zip
    • LCS Asset Name and LCS Asset Description: Use descriptive values to identify this package on the list when uploaded to the LCS Asset Library. More information about Azure Pipeline variables on the docs here for the build and here for the release.

      • Example: $(Release.ReleaseName)-$(Build.BuildNumber)
    • It will look more or less like that:

3. Done! now what?

Use the Create a release button to create a new release manually (or launch a build, if you configured the Continuous Integration trigger):

Hopefully your results will look like that (otherwise check the logs to understand what’s happening, most common error so far is authentication with the AAD app):

If everything went well, you have a new file in the Software deployable package folder on the LCS Asset Library.

To get more information about this release and the setup process check the official announcement here and this blog post.

Hope these instructions are useful to understand how to setup this first automation task, that hopefully won’t be the last one. Check the documentation for upcoming changes regarding Developer tools and application lifecycle management.

Published first at “Dynamics AX in the Field”, the blog from the Premier Field Engineering team at Microsoft.

Last updated — Oct/2020:

  • New screenshots as the Application Registration in AAD (step #1) has changed significantly.
  • Corrected some hyperlinks.
  • Small typos fixed.

Last updated — Sept/2022:

  • Recovered lost screenshots as per reader’s request.
  • Fixed markup, broken links and some typos.

Posts in this series