BcContainerHelper version 2.0.1

Version 2.0.1 of BcContainerHelper was shipped with a number of very exciting new featuers. This blog post will list the features and I will have to document them elsewhere.

  • Run-AlPipeline and Compile-AppInBcContainer with -failOn ‘error’ will now mark a build as succeeded with Warnings if there are warnings in the build.
  • New-BcContainer with -FilesOnly will create a container with no service tier, no sql database, no IIS, just all the files from a normal docker container copied to a container
  • Compile-AppInBcContainer with -CopySymbolsFromContainer will copy symbols from the container instead of downloading them from the service tier.
  • New function New-BcAuthContext is a new function to create an authorization context (with an AccessToken) for a Business Central online tenant. Invoke the function using -includeDeviceLogin and you will have an AccessToken in seconds. Store the refresh token in a keyvault and you will have access to a new AccessToken in your pipeline for 90 days.
  • New function Renew-BcAuthContext will renew the authorization context (if the AccessToken is about to expire). This function is used within functions in BcContainerHelper to ensure that the token is still valid even if the pipeline/function takes more than 60 minutes.
  • Compile-AppInBcContainer with -bcAuthContext and -environment will compile an app and use an online Business Central sandbox environment for downloading symbols.
  • Publish-AppToBcContainer with -bcAuthContext and -environment will publish an app to an online Business Central sandbox environment.
  • Import-TestToolkitToBcContainer with -TestRunnerOnly will import Test Runner only (no framework, no libraries, no tests)
  • Import-TestToolkitToBcContainer with -bcAuthContext and -environment will import the test toolkit (-includeTestRunnerOnly or -includeTestFrameworkOnly – not Test Libraries and not Tests) to an online Business Central sandbox (Test Framework (Any, Assert, Variable Storage) will be available online within the next weeks – today only Test Runner is possible)
  • Run-TestsInBcContainer with -bcAuthContext and -environment will run tests in an online Business Central sandbox environment
  • New function Install-BcAppFromAppSource with -bcAuthContext and -environment uses page 2503 to install an AppSource App in an online Business Central environment. The implementation of this function will be changed to use the Admin Center API once that API supports installing AppSource Apps.
  • Run-AlPipeline with -bcAuthContext and -environment will run a full Al Pipeline using an online Business Central sandbox environment. This is useful for running pipelines for PTEs with dependencies on 3rd party extensions you don’t control.
  • Get-BcArtifactUrl has two new parameters (before and after) to only take artifacts created before or after a certain timestamp into consideration. Using Before or After makes the function considerably slower.
  • New function Convert-BcAppsToRuntimePackages used to convert an array of Apps to runtime packages for a given version (ArtifactUrl). Goal is to make it possible for partners to automate the sharing of 3rd party runtime apps for people using PTEs without sharing IP, wait for the blog post.
  • Stacktrace when an error happens within the scriptblock of Invoke-ScriptInBcContainer now contains a lot more useful information

I will create a number of blog posts describing these things in greater detail.

Also, based on feedback, I better spend some time going through old blog posts and ensure that the content matches current functionality AND create an actual reference documentation on current functionality instead of blog posts only…

Feedback/Questions I am 100% sure that I will get

Why did I add functionality in the BcContainerHelper to work with online environments? Why not create these functions in a separate PowerShell module? and why not enable compiling and publishing without using containers?

The reason that the new functions exists inside BcContainerHelper is that I did not want to create another PowerShell module and have BcContainerHelper have a dependency on that, simply due to time constraints and the reason for still using containers is that with containers, I can be sure that all the pre-requisite components are installed in the right locations and that I do not contaminate the host. In the end, the changes to the compile-, publish-, run-tests- etc. functions to work with online environments is very limited – it is really just the authentication and then calculating the URL to connect to.

Why is New-BcAuthContext not using ADAL (Active Directory Authentication Library) or MSAL (Microsoft Authentication Library)?

ADAL is history, nobody should use ADAL today when creating new functionality. MSAL is future and I did investigate using MSAL, but I really didn’t want to add a dependency in BcContainerHelper at this time. I didn’t want to struggle with people having wrong versions of MSAL or having other things conflicting with MSAL. Also MSAL might go to dotnet core before I can and stop supporting dotnet framework altogether. So, I decided to go native. I might change the implementation in the future though.

Stay tuned for a number of upcoming blog posts.

Freddy Kristiansen
Technical Evangelist

How to use Run-AlValidation

When releasing the first version of Run-AlValidation in BcContainerHelper, i did a quick blog post about the function here. This blog post serves to explain some common scenarios of how to run the function. The blog post will also explain the parameters of Run-AlValidation a bit more in depth, for people to have a good chance of using the function before submitting for AppSource Validation.

Continue reading

TimeStampServer – you had one job!

The important part of this blog post: Please make sure to upgrade to BcContainerHelper 1.0.18 or reconfigfure the timestampServer in your existing version.

December 30th 2020 we got a number of apps for validation failing due to a wrong timestamp signature. Some partners discovered this before submitting and filed an issue on github here, complaining about this error: “The timestamp signature and/or certificate could not be verified or is malformed.

I was enjoying a nice walk in the forest with my dogs, but my phone would reveal increased activity on github and emails from partners running into this strange issue.

Continue reading

Run-AlValidation and Run-AlCops

On December 1st, I co-hosted a webinar about how people can make sure that their app passes AppSource Validation. Until now, I have always been preaching that people should run CI/CD and include AppSourceCop validation in their CI/CD pipeline, which is supported in the Run-AlPipeline function. But…, as I prepared for the session, it became evident that it would be really helpful to have a function, which basically does exactly the same as our validation pipeline.

Continue reading

Using GitHub for DevOps

For the last 2 years we have had the Hands On Lab (https://aka.ms/cicdhol) in a few iterations using Azure DevOps as the platform. Latest revision was published a few weeks ago.

There are however multiple platforms for DevOps out there and I wanted to investigate the functionality of Github, which also is part of the Microsoft family and probably the biggest provider of devops services to developers in the world.

Continue reading

18 hours of no containerhelper…

Friday morning around 6am. I had just kicked off a few validation builds when they started failing. Failing builds can happen and typically there is a valid reason for this, but in this case – ALL builds was failing and looking in the logs I quickly realized that this problem was something different.

PowerShell Gallery was down, PowerShell Gallery had an outage and it took a stunning 18 hours before it was back online…:-(

Continue reading

Multitenant sandbox containers changes behavior…

With the change to BcContainerHelper, sandbox containers became multitenant by default. This means that you have to remember the ?tenant=default in the WebClient and the “tenant” : “default” in launch.json.

The reason for this change was, that sandbox containers needs to feel and act like online tenants and online tenant are… – tenants. I did however miss out on one thing, which I was made aware of over the weekend.

Continue reading

Troubleshooting Business Central on Docker

This blog post is not really a troubleshooting guide (although there is a small TSG at the end). It is more like a brain dump of what I have seen over time and how I would approach a trouble shooting session. I have divided it into 6 sections:

  1. Dockers worst enemy (just FYI)
  2. Installing Docker
  3. Installing BcContainerHelper
  4. Creating a Business Central container
  5. Keep the script, not the Container
  6. Frequently seen docker errors

Going forward, I will add a link to this blog post to all issues on https://www.github.com/microsoft/navcontainerhelper/issues, where the answer to the issue is in this blog post.

Continue reading