Sorry, we found 0 results. Please try another query.
Showing max 10 of results

Add Azure Search Service to my blog

I was using the Google site search as as search service for this blog for a long time now. However, after I saw this article from Max Melcher where he added the Azure Search Service to his blog, I thought I should give it a try as well.


First of all, you need an Azure Subscription. Then in the Azure Portal click Create a resource then search for Azure Search.



My blog is static HTML generated by Hexo. It also generates a content.json file containing all posts (titles, text, publish date, tags).
This file is stored in Azure Blob Storage where the Search Service easily can index it. Just click Import data.

Here is the configuration:


You can optional add some cognitive services to extract special entities like company names or do some text analysis. After that you have to specifiy what data you want in the index:


After the indexing is complete, you can query the search service via a REST API. You can test it in the search query explorer directly from within the Aure Portal.


I’ve added some lines of Javascript to my blog to fetch the search results and here we go.



To make it easier to find what you are looking for, I shoud add a tag filter and some date sorting.

Restore my AzureVM from Backup

I have an Azure VM for development purposes. You can read how I’ve created it here.

Ok so you know how it is setup including the backup part. Backup in Azure is awesome because it is just a few clicks away.
I’m running Windows 10 on the VM and I’ve enabled Insider Previews in the “Slow Ring”.
Not a really good idea.

A few days after the update the VM stopped booting. Here is the Boot Diagnostics screen:


It is a VM so there is no chance to click in this screenshot. Even a reboot did not fix it.
Thankfully, I have the VM backup configured so I can go back with the OS disk before the insider preview was installed.


Here are the steps to restore the OS disk, but without touching the existing VM and the VM configuration.

  1. Create a new storage account. It will be used as a temp storage for the restored disks. It must be a Standard (not Premium) tier storage account.

  2. Go to the Backup blade and select Restore VM


  1. If you want to keep all your VM settings select Restore disks as the restore type, then select the storage account created in step 1.


  1. Wait until the disks are restored. Now you need to create a new managed disk based on the restored vhd file.
    Click “Create a new resource” and search for Managed Disk.
    Create a new managed disk within the same resource group as your VM and select Storage blob as the source type. Make sure you select the correct OS type.


  1. Now there is only one challenge left: Swap the existing disk with the restored OS disk. A walkthrough can be found in the Azure docs
$vm = Get-AzureRmVM -ResourceGroupName myResourceGroup -Name myVM 

$disk = Get-AzureRmDisk -ResourceGroupName myResourceGroup -Name newDisk

Set-AzureRmVMOSDisk -VM $vm -ManagedDiskId $disk.Id -Name $disk.Name 

Update-AzureRmVM -ResourceGroupName myResourceGroup -VM $vm

If you do not have and or you do not want to install the Azure PowerShell commandlets, you can just visit to have a shell directly in the browser.


Ultraschall Füllstandssensor für die Regenwasser Zisterne


Ich habe im Garten eine Regenwasser Zisterne, etwa wie diese. Das Regenwasser vom Dach wird dort gesammelt und kann dann zum Gießen, Rasensprengen, o.ä. verwendet werden.

Ich möchte nun gerne wissen wie voll die Zisterne gerade ist, und das natürlich ohne rein zu sehen.

Die Idee ist, einen Ultraschallsensor (wie er am Auto zum Einparken verwendet wird) zu nutzen.


Für die Realisierung habe ich mir folgende Teile besorgt:

Achtung: Vor dem genannten Ultraschallsensor hatte ich zunächst diesen probiert, da er eine längere Zuleitung hat und in einem Gehäuse verpackt ist. Entgegen der Beschreibung scheint es 2 verschieden Versionen zu geben, einmal mit dem Trigger Signal und einmal als Serielle Version. Das muss man bei der Anbindung wissen.

Ich habe das ganze mit einem Raspberry gelöst, geht aber natürlich auch auch mit einem Arduino (o.ä.). Ich hatte jedoch noch einen Raspberry Pi 2 mit USB WLAN Modul rumliegen.

Zusammengebaut sieht das ganze dann so aus:
/images/2018/Ultraschall1_orig.jpg /images/2018/Ultraschall2_orig.jpg

Die Dose habe ich in der Zisterne am Deckel verschraubt, so dass der Ultraschallsensor auf die Wasseroberfläche zeigt und den Abstand misst.


Softwareseitig habe ich, wie bereits bei anderen Projekten, auf die bewährte Lösung gesetzt: .NET Konsolenanwendung mit mono.

Diese läuft in einem Cron Job um regelmäßig über die GPIO Ports den Ultraschallsensor zu triggern und die Entfernung zur Wasseroberfläche zu messen.
Das Ergebnis wird dann per UDP an meine Loxone Installation gesendet. Mit einem einfachen Status Baustein zeige ich den aktuellen Füllstand (derzeit nur Voll/Halbvoll/Leer) an.


Hier verwendete Produktlinks sind Amazon Affiliate Links. Wenn du sie benutzt, hilfst du mir mehr Gadgets zu kaufen.

Create a dev machine in the cloud for daily use

I’m a software developer, so today I want to show how to create a development VM in Azure.

Create VM

Go to Azure and create an account if you do not yet have one. If you have an MSDN (aka Visual Studio) subscription log in and activate your free Azure credits right there.
Now in the Azure Portal click Create a ressource and search for Visual Studio. Now select Visual Studio Community Edition which is free or Enterprise if you have an Enterprise subscription. I’ve choosen VS on Windows 10, but you can even select VS on Windows Server 2016.

First you have to give it a name and select the storage type. Default is SSD which I also recommend for the best performance. Then enter a username you want to use and a password.

Now you have to choose a size of your new VM. As you can see, there are a lot of options available. The estimated price would be the price if your VM is up and running 24/7 for a month. However, my dev machine will only run if I’m using it, so I can choose a bigger machine even if I have not enough credits to run this machine for an entire month. Each ressource is billed per minute which is awesome. I will go with 4 CPUs and 16GB RAM. So running this machine for one hour will cost me about 0,20 EUR.

In the last step you can define networking stuff, but I will use the defaults here for now.


Just one setting is really important: Auto-shutdown. As you can see here, I have enabled auto-shutdown and set it to 18:00. That means: Whenever you leave the office and forgot to shutdown your machine, Azure will do it for you at the specified time. You can even send notifications before shutdown which can be configured later.


Now wait a few minutes until the machine is provisioned.
The next step is to set a static IP for your machine and a DNS name if you want to. Click on your VM in the portal and then Networking. There you can see your public IP. If you click it, you can define a DNS name as well and switch from dynamic to a static IP.
/images/2018/azurevs4_orig.jpg /images/2018/azurevs5_orig.jpg

Disks and Backup

Now go to the Disks tab in your VM and add a new data disk. There you can store all data independently from the rest of your VMs OS disk. Also it is on another LUN so you have done everything you can for the best performance ;-)

What I’ve done now is to go to the Backup tab and configure an automatic daily backup. With this backup you can restore the VM to any day in the last 30 days. You can even restore single files on your disks. Therefore Azure mounts the disk you selected locally and you can copy single files from the disks. Awesome!

Keep in mind: Disks/Storage and Backup have it’s own price tag, so check that before configuring it.


Using it

You can now Remote Desktop into the machine via the Connect button on the VM overview tab. If you have selected a static IP and DNS name you can connect using them.
Now install all your favorite dev tools within the VM. Visual Studio is already installed but needs to be updated (of course).

How to use Microsoft Flow to start and stop the VM from my mobile

First of all, go to this blog post from Søren Rasmussen. He describes how to automate startup and shutdown of Azure VMs with the help of Azure Automation Services. After you have created the so called runbooks go to the startup runbook, click Webhooks->Add Webhook
/images/2018/azurevs7_orig.jpg /images/2018/azurevs8_orig.jpg
Make sure you copy the webhook URL before clicking OK, because there is no way to see the URL again.
The URL looks like:
Do the same for the shutdown runbook.

Create Flow buttons

Login with your account to Flow. Click on My Flows -> Create from blank.
You should see a Flow button for mobile.
Then add a new action. Search for http and selet POST as the method and paste the webhook URL from your runbook.

That’s it! On your mobile download the Flow app and there you can see your buttons and start your VM on the way to the office.

Note: It can take a minute (on my first try it took a few more minutes) to kick of the runbook and start the VM.

Add comments to this blog

I have had no comments enabled since I have moved my blog to hexo. There are some solutions with Disqus available, but I thought it is a good chance to build it myself.

First of all I created a new storage account in Azure to store all comments in table storage which is simple, easy to use, cheap and fast.
Then I needed an API which stores and retrieves the comments from the table. Azure Functions is perfect, because it has ready-to-use templates for HTTP POST and GET with table storage. It generates a url to call the functions.
In my javascript within this blog I have added a few lines of code to add and render existing comments.

It is a first try and the design is awful, but it works. I will monitor it over the next few weeks and see if it works or if I move to something like Disqus.