Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Reading Notes #601

It's reading notes time! It is a habit I started a long time ago, where I share a list of all the articles, blog posts, and books that catch my interest during the week.

Having interesting content? Share it! 

Suggestion of the week

  • Announcing: Azure Developers (Mehul Harry) - Looking forward to this event. I have the pleasure to present a session with Jerry Nixon about Data API Builder. Join us!


  • Demystifying Azure CLI pagnination (Jeremy Li) - That's great! It's so sad when all the information is "throw" on us without any control and it's on us to find our "needle" we are looking for in those screens full of line. This will definitely helps.


Open Source

~ Frank

My Ubuntu laptop finally works with my docking station!

Targus USB-C Docking Station

I've been running Ubuntu on my personal laptop, a Dell Inspiron 13. I love it. It's slim, performant and I can code, play, read, stream without any difficulty. Yet when I try to use my bigger PC monitors by connecting my laptop to a docking station, I've had a lot of trouble. I've tried 2 docking stations, but none of them worked with Ubuntu. Some solutions found online suggest rebuilding my kernel, but I didn't want to do that, it felt too extreme for what should be trivial.

This post is about how I finally got my docking station to work with Ubuntu 22.04.

My current docking station is a Targus USB-C Docking Station and it works perfectly with other Windows devices. While doing some cleaning on my desk a logo catches my attention on the dock; the Displaylink logo. And that was the beginning of the end for the problem with that dock station.

DisplayLink logo on a Targus USB-C Docking Station

After a quick search (aka Googling with DuckDuckGo) I found exactly what I was looking for on Synaptics web site. A solution for the older Linux versions! 

Following the instructions: How to install DisplayLink Software - Ubuntu, I was able to downloads the Synaptics Ubuntu Driver Download and install them in a few minutes. After a reboot... It worked!

I hope it will help others with the same problem. 

Reading Notes #522

Yep! It's Monday again :) 
 Already time to share new reading notes. Here is a list of all the articles, and blog posts that catch my interest during the week. 

If you think you may have interesting content, share it!





Reading Notes #519

Good Monday, Already time to share new reading notes. Here is a list of all the articles, and blog posts that catch my interest during the week.

If you think you may have interesting content, share it!

Suggestion of the week




Reading Notes #455

The suggestion of the week




Reading Notes #392

The suggestion of the week


  • Andrew Connell's Blog (Andrew Connell) - This nice post is the second of a series of three. It explains how to do every step but also why the author decided to do that.




Reading Notes #313

roy_sky_ansi2Suggestion of the week





How to access an SQL Database from an Azure Function and Node.js

The other day, a friend asked me how he could add some functionality to an existing application without having access to the code. It the perfect case to demo some Azure Functions capability, so I jumped on the occasion. Because my friend is a Node.js developer on Linux, and I knew it was supported, I decided to try that combination. I know Node, but I'm definitely not and expert since I don't practice very often.

This post is my journey building that demo. I was out of my comfort zone, coding in Node and working on a Linux machine, but not that far... Because these days, you can "do some Azure" from anywhere.

The Goal

Coding an Azure Function that will connect to an SQL Database (it could be any data source). Using Node.js and tools available on Unbuntu.

Note: In this post, I will be using Visual Studio Code, but you could also create your function directly in the Azure Portal or from Visual Stusio.

Getting Started

If you are a regular reader of this blog, you know how I like Visual Studio Code. It's a great tool available on Mac Linux and Windows and gives you the opportunity to enjoy all its feature from anywhere feeling like if you were in your cozy and familiar environment. If VSCode is not already installed on your machine, go grap your free version on

Many extensions are available for VSCode, and one gives us the capability to code and deploy Azure Function. To install it, open VSCode and select the extension icon and search for Azure Function; it's the one with the yellow lighting and the blue angle brackets.


Create the Azure Function

To get started let's great an Azure Function project. By sure to be in the folder where you wish to create your Function App. Open the Command Pallette (Ctrl + Shift + p) and type Azure Function. Select Azure Functions: Create New Project. That will add some configuration files for the Functions App.

Now Let's create a Function. You could reopen again the Command Palette and search for Azure Function: Create Function, but let's use the UI this time. At the bottom left of the Explorer section, you should see a new section called AZURE FUNCTIONS. Click on the little lighting to Create a new Function.


After you specify the Function App name, the Azure subscription and other little essential, a new folder will be added in your folder structure, and the function is created. The code of our function is in the file Index.js. At the moment, of writing this post only Javascript is supported by the VSCode extension.

Open the file index.js and replace all its content by the following code.

var Connection = require('tedious').Connection;
var Request = require('tedious').Request
var TYPES = require('tedious').TYPES;

module.exports = function (context, myTimer) {

    var _currentData = {};

    var config = {
        userName: 'frankadmin',
        password: 'MyPassw0rd!',
        server: '',
        options: {encrypt: true, database: 'clouden5db'}

    var connection = new Connection(config);
    connection.on('connect', function(err) {

    function getPerformance() {

        request = new Request("SELECT 'Best' = MIN(FivekmTime), 'Average' = AVG(FivekmTime) FROM RunnerPerformance;", function(err) {
        if (err) {

        request.on('row', function(columns) {
            _currentData.Best = columns[0].value;
            _currentData.Average = columns[1].value;;

        request.on('requestCompleted', function () {

    function saveStatistic() {

        request = new Request("UPDATE Statistic SET BestTime=@best, AverageTime=@average;", function(err) {
         if (err) {
        request.addParameter('best', TYPES.Int, _currentData.Best);
        request.addParameter('average', TYPES.Int, _currentData.Average);
        request.on('row', function(columns) {
            columns.forEach(function(column) {
              if (column.value === null) {
              } else {
                context.log("Statistic Updated.");



The code just to demonstrate how to connect to an SQL Database and do not represent the best practices. At the top, we have some declaration the used the package tedious; I will get back to that later. A that, I've created a connection using the configuration declared just before. Then we hook some function to some event. On connection connect the function getPerformance() is called to fetch the data.

On request row event we grab the data and do the "math", then finally on requestCompleted we call the second sub-function that will update the database with the new value. To get more information and see more example about tedious, check the GitHub repository.

Publish to Azure

All the code is ready; it's now time to publish our function to Azure. One more time you could to that by the Command Palette, or the Extension menu. Use the method of your choice and select Deploy to Function App. After a few seconds only our Function will be deployed in Azure.

Navigate to and get to your Function App. If you try to Run the Function right now, you will get an error because tedious is not recognized.

Install the dependencies

We need to install the dependencies for the Function App, in this case tedious. A very simple way is to create a package.json file and to use the Kudu console ton install it. Create a package.json file with the following json in it:

    "name": "CloudEn5Minutes",
    "version": "1.0.0",
    "description": "Connect to Database",
    "repository": {
       "type": "git",
       "url": "git+"
    "author": "",
    "license": "ISC",
    "dependencies": {
        "tedious": "^2.1.1"

Open the Kudu interface. You can reach it by clicking on the Function App then the tab Platform features and finally Advanced tools (Kudu). Kudu is also available directly by the URL [FunctionAppNAme] (ex: ). Select the Debug console CMD. Than in the top section navigate to the folder home\site\wwwroot. Drag & drop the package.json file. Once the file is uploaded, type the command npm install to download and install all the dependencies declared in our file. Once it all done you should restart the Function App.


Wrapping up & my thoughts

There it is, if you go back now to your Function and try to execute it will work perfectly. It's true that I'm familiar with Azure Function and SQL Database. However, for a first experience using Ubuntu and Node.js in the mix, I was expecting more resistance. One more time VSCode was really useful and everything was done with ease.

For those of you that would like to test this exact function, here the SQL code to generate what will be required for the database side.

    CREATE TABLE RunnerPerformance(
        Id           INT IDENTITY(1,1)  PRIMARY KEY,
        FivekmTime   INT

    CREATE TABLE Statistic(
        Id          INT IDENTITY(1,1)  PRIMARY KEY,
        BestTime    INT,
        AverageTime INT

    INSERT Statistic (BestTime, AverageTime) VALUES (1, 1);

    DECLARE @cnt INT = 0;

    WHILE @cnt < 10
    INSERT INTO RunnerPerformance (FivekmTime)
    SET @cnt = @cnt + 1;

Video version


Create and Deploy .NET Core WebApp to Azure from Linux

(Ce billet en aussi disponible en français.)

The other day, I was glued to my PC, and I had spare time (yah, I know very unusual). Since .Net Core 1.0 was just released few days before, I decide to give it a try. To add an extra layer of fun in the mix, I decided to do it from my Ubuntu VM. In less than 15 minutes, everything was done! I was so impressed I knew I needed to talk about it. That's exactly what this post is about.

The preparation

Before we get started, it's important to know which version of Ubuntu you are using, because some commands will be slightly different. To know the version you are running you simply need to click the gear in the top right of the desktop screen and select About this Computer. In my case, since I'm using Ubuntu 14.04 LTS, I will be using command related to this version. If you are using a different version, please refer to .NET Core documentation.


Now we need to install .Net Core. Nothing more easy. Open a Terminal (Ctrl+Alt+T) and type those three commands:

# Setup the apt-get feed adding dotnet as repo
sudo sh -c 'echo "deb [arch=amd64] trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
apt-key adv --keyserver --recv-keys 417A0893

# Get the latest packages
apt-get update

# Install .NET Core SDK
sudo apt-get install dotnet-dev-1.0.0-preview2-003121
Once it's all done you can type dotnet --info and you should see something like that.


Create the Local WebApp

From the same Terminal we will create an empty folder for our solution and move into it. Execute these commands.
mkdir demodotnetweb
cd demodotnetweb
We now want to create our new web project. This is done by the command dotnet new, but we need to specify the type otherwise it will create a console application.
dotnet new -t web
Now to download all the references (nuget packages) of our project required, execute the following command:
dotnet restore
Base on the speed of your Internet connection and how many dependencies are required, this can take from few seconds to more than one minute.
To test if our solution works locally type the command:
dotnet run
That will compile our solution and start an AspNetCore Internal hosting. Launch a web browser and go to http://localhost:5000 to see the App in action.


Deploy to Azure

To deploy our new project to the cloud, we will use the continuous deployment capability of Azure. First, navigate to and create a Web App.


Once the the application is created, you should see the This web app as been created message when you navigate to the [nameofWebApp]


It's now time to add a local Git repository. In the WebApp Settings select Deployment source. Click on the Configure Required Settings, then select the Local Git Repository option.


After setting the user credential for the repository, we can get the URL from the Essential section.


Back to our Ubuntu Terminal, we will have to execute these commands:

# create a git repository
git init
# commit all files
git commit -m "Init"

# Add the remote repository
git remote add azure

# Push the code to the remote
git push azure master
After a minute or so you should have your WebApp online!


Voila! That was fun!.

Reading Notes #239




Automating Docker Deployment with Azure Resource Manager

Recently, I had to build a solution where Docker container were appropriate. The idea behind the container is that once there are built you just have to run it. While it's true, my journey was not exactly that, nothing dramatic, only few gotchas that I will explain while sharing my journey.

The Goal

The solution is classic, and this post will focus on a single Virtual Machine (VM). The Linux VM needs a container that automatically runs when the VM starts. Some files first download from a secure location (Azure blob storage) then passed to the container. The solution is deployed using Azure resources manager (ARM). For the simplicity, I will use Nginx container but the same principle applies to any container. Here is the diagram of the solution.


The Solution

I decided to use Azure CLI to deploy since this will be also the command-line used inside the Linux VM, but Azure PowerShell could do the same. We will be deploying an ARM template containing a Linux VM, and two VM-Extension: DockerExtension and CustomScriptForLinux. Once the VM is provisioned, a bash script will be downloaded by CustomScriptForLinux extension from the secure Azure blob storage myprojectsafe, then executed.

Reading Notes 193

chaos-monkey-3_480Suggestion of the week




Image from  Inside Azure Search: Chaos Engineering

Change Font Color in Gnome Panels


I don't know if you are like me, but I prefer darker themes.


But with Ubuntu no UI interffface is present be default to change the color of the font in Gnome panels. Here the simple way I found.

  1. Open a terminal and type:


    sudo gedit .gtkrc-2.0

  2. Then a empty file will open so copy-paste this code:


    include "/home/autocrosser/.gnome2/panel-fontrc"style "desktop-icon"
    NautilusIconContainer::frame_text = 1
    text[NORMAL] = "#000000"
    NautilusIconContainer::normal_alpha = 70
    class "GtkWidget" style "desktop-icon"
    style "panel"
    fg[NORMAL] = "#ffffff"
    # fg[PRELIGHT] = "#000000″

    # fg[ACTIVE] = "#000000"
    # fg[SELECTED] = "#000000″

    # fg[INSENSITIVE] = "#8A857C"
    # bg[NORMAL] = "#000000″

    # bg[PRELIGHT] = "#dfdfdf"
    # bg[ACTIVE] = "#D0D0D0″

    # bg[SELECTED] = "#D8BB75″

    # base[NORMAL] = "#ffffff"
    # base[PRELIGHT] = "#EFEFEF"
    # base[ACTIVE] = "#D0D0D0″

    # base[SELECTED] = "#DAB566″

    # base[INSENSITIVE] = "#E8E8E8″

    # text[NORMAL] = "#161616″

    # text[PRELIGHT] = "#000000″

    # text[ACTIVE] = "#000000″

    # text[SELECTED] = "#ffffff"
    # text[INSENSITIVE] = "#8A857C"
    widget "*PanelWidget*" style "panel"
    widget "*PanelApplet*" style "panel"
    class "*Panel*" style "panel"
    widget_class "*Mail*" style "panel"
    class "*notif*" style "panel"
    class "*Notif*" style "panel"
    class "*Tray*" style "panel"
    class "*tray*" style "panel"

    That time I change the color code of: fg[NORMAL] = "#FFFFFF". You can change this fffor any color by using the #RRGGBB equivalent code.

  3. Save. Close the editor. Re-log and Enjoy!

  If you dont know the code for the color you want you can go here, Or you can use gcolor2.   To install it type in a terminal


sudo apt-get install gcolor2

And when you are done, type: gcolor2 and voila!

I hope this little trick will make it eiser for you!