Solutions
Markets
References
Services
Company
Get logs and execute commands on Azure Container Instances

Get logs and execute commands on Azure Container Instances

3. May 2018

Get logs and execute commands on Azure Container Instances

Azure Container Instances (ACI) have recently reached GA and adoption and use cases have come up in a lot of places. Two examples of that would be my NAV/BC on ACI quickstart template and the API-enabled NAV instance on ACI you can create from my VS Code extension. Two very nice features have also been added to ACI: The ability to directly get logs from your ACI and execute a command in it

The TL;DR

If you want to get the logs from your ACI do

az container logs --name <containername> --resource-group <groupname>

and if you want to execute a command, e.g. powershell in your ACI do

az container exec --name <containername> --resource-group <groupname> --exec-command powershell

. After that just do whatever you need to do in PowerShell. This gives you the flexibility to change everything you need in your ACI, making it a fully functional environment.

The details

Actually, in this case I don’t have anything to share additionally, so I’ll just end it with a quick sample of restarting your NAV Server instance in your NAV ACI:

Thanks a lot to Anders Liu for sharing this (weeks ago…)!


4 Kommentare zu “Get logs and execute commands on Azure Container Instances”

  1. Hey Tobias,
    Thanks for sharing it.

    I tried the command you suggested to enter the powershell of container. But it does have some glitches. Anything i type within powershell results to strange symbols. For e.g. here i typed ‘dir’ and it gave me all these symbols

    C:\Users\gintautas>az container exec –resource-group “mylab” –name mvtestcontainer10 –exec-command powershell
    [2J[H[37;40mWindows PowerShell
    Copyright (C) 2016 Microsoft Corporation. All rights reserved.

    PS C:\> [4HPS C:\> [1;33;40md[22;37;40m[K[4;9H[4;10H[4HPS C:\> [1;33;40mdi[22;37;40m[K[4;10H[4;11H[4HPS C:\> [1;33;40mdir[22;37;40m[K[4;11H[4;12H

    1. Hey,

      thanks for your feedback. I’ve seen that a couple of times before as well, but am not sure when and why it happens. I usually use the integrated PowerShell in VS Code and that seems to not have that problem. As a fallback I also have never seen it when use the cloud based Azure Shell (bash) to connect

  2. Hello,

    Is it possible to use this approach to copy files from a local drive to the azure instance container ? I would like to use this appproach to copy my own database to the container instance.

    1. Hello Tony,

      the easiest option would be to set the env param “bakfile”, but I haven’t exposed that in the template. I’ll give it a try but am not sure how soon. The other option would be to connect to the ACI with PowerShell, get your bak, restore it and configure the NAV instance to use that. However this approach requires some manual work after spinning up the ACI, so from my point of view it takes away most of the appeal of ACIs


Leave a Reply

Your email address will not be published. Required fields are marked *