Deploying from DevOps the right way (Part 2): Deploying to OnPrem Business Central environments with the automation API

You might have read my previous blogpost on how to enable the “external deployment” in an OnPrem Business Central environment. Well, that post deserved an “extension” as I didn’t provide examples on how to deploy with PowerShell – which you would be able to do within Azure DevOps.

Scenario

The scenario is still the same: you have all these OnPrem customers, where you would like to deploy your apps to. Microsoft is clear: just install a DevOps agent on all those customers. The alternative that I try to give is – well, don’t install the devops agent, but just make “External Deployment” possible by following my steps in my previous post, and use the Automation API, just like you would for Business Central SaaS. Sidenote: this API needs to be accessible from your company. So we make sure that the customer enables our IP in their firewall to be able to access this automation API directly from our location.

PowerShell

Since I don’t use PowerShell in DevOps (suplise, suplise), I created an example-script for you in my repo here: https://github.com/waldo1001/Cloud.Ready.Software.PowerShell/blob/master/PSScripts/DevOps/DeployWithAutomationAPI.ps1
Just a few things worth to mention:

  • It’s good to have the app.json and the app-file in the artifacts, to be able to easily get the details about the app being released
  • The publish is just a matter of streaming the file in the request
  • Notice I’m using the “beta” version of the API. I was able to publish the extension with v1.0, but I wasn’t able to get the deployment status – only through the beta-version. Since this is an unsupported way of deployment, I don’t think I can ask Microsoft to help me on this ;-).
  • You would be able to loop the call about the deployment progress, to see if it was successful or not – basically a loop until the status says “completed” or “failed”.

The main part here obviously is the Patch-method to upload the extension. The external deployer you installed will do the rest.. .

ALOps

As said, I don’t use PowerShell anymore, because I’m using ALOps, just because it so much more hassle-free .. and we see that many people are starting to use ALOps as well, also for community purposes. Nice! This means community projects are also getting decent build pipeline in stead of none – and it’s free, so why not ;-).
In ALOps, we created the “ALOps Extension API” step, which you can use to publish an extension through the Automation API OnPrem. The easiest way to do that is by simply introduce one step, and set the “Batch Publish” interaction. Basically it will get all app-files you selected as artifacts, figure out the order to publish for you, and install all artifacts that you have set up in your release-step. Easy peasy. It doesn’t care if it’s in Docker or not .. If the endpoint is available, the external deployer is installed, then your publish will work. Here is the setup in the classic editor which releases 22 apps – one simple step, with only 1 real parameter to fill:

Or in yaml:

steps:
 - task: hodor.hodor-alops.ALOpsExtensionAPI.ALOpsExtensionAPI@1
   displayName: 'Batch Publish'
   inputs:
     interaction: batch
     api_endpoint: 'https://thedestinationbc/bc/api'
     authentication: windows 
5.00 avg. rating (97% score) - 1 vote

Permanent link to this article: https://www.waldo.be/2020/06/30/deploying-from-devops-the-right-way-part-2-deploying-to-onprem-business-central-environments-with-the-automation-api/

2 comments

    • Julien on June 30, 2020 at 1:08 pm
    • Reply

    Thanks for this !
    You actually helped me resolving the deployment status, as I wasn’t able to get it from a SaaS environment, so passing beta instead of v1.0 in the URL worked.

    Accordingly to this github issue, it is probably a bug with the 16.2 version.
    https://github.com/microsoft/AL/issues/5973

      • waldo on June 30, 2020 at 1:11 pm
        Author

      Cool!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.