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

Start my Azure VM based on my Tesla location

My car has an API… now what?

I have a Tesla Model 3 and it is a computer on wheels. Next-level IoT ;-)
I’m using the Tesla API Scraper to log some data from the car to a local InfluxDb. It has a nice Grafana dashboard like this one:
/images/2019/tesla1.png

What can I do with the data?

My main developer machine is a VM in Azure (see previous post). It shutsdown automatically every evening to save costs, but I have to start it manually in the morning.
Now that the InfluxDb contains near real-time location data I’ve created a simple .NET core console app to connect to the InfluxDb, gets the latest location and check the distance to my work location.
If the car is near my work location the console app posts to an Azure Automation WebHook to start the VM. Awesome!

https://media.giphy.com/media/ZZkCo8zKWtt2ZgozfX/giphy.gif

Track my expenses

How is it working?

To track my personal expenses throughout a month, I have created a simple web form with Vue.js and Vuetify and the Azure Storage JavaScript Client Libraries. It is hosted on an Azure static web site.

/images/2019/expenses1.jpg

On save, the entry is stored in an Azure storage queue.
From there I have created a Flow to append the data to an existing Excel sheet hosted on SharePoint Online.

/images/2019/expenses2.jpg

Add some (pre-built) machine learning to it

Microsoft just launched the private preview to understand receipts with Form Recognizer.
So to make it even easier to enter new receipts, I have added a capture button to my web app to make a photo from the receipt and send it to the Form Recognizer API.
The API returns a JSON response with fields for Total, MerchantName, TransactionDate, and a lot more. I grab them and populate the input fields.

Visual Studio Code Extension to see the Azure DevOps Agent Status

We are using Azure DevOps / Pipelines for build and release management in our team.
I wanted to have a quick look if the hosted build agent is currently free or in use, so I have created a Visual Studio Code Extension to display the info in the status bar.

/images/2019/devops-status.gif

DOWNLOAD EXTENSION

Extension

  • To get started you create a new project with yeoman: yo code
  • The docs are really helpful.
  • There are a lot of samples for the different use cases here

The source of my extension can be found here in my GitHub repo

DevOps API

To connect to the Azure DevOps REST API you need a personal access token, which can be obtained from https://dev.azure.com/YOUR_ORG -> Your Account -> Security

/images/2019/devops-pat.jpg

The API documentation can be found here.

The specific API I wanted to use is missing in the documentation which maybe means it is not for public use (yet?). However the DevOps portal is using the same API so it works for now:

GET https://dev.azure.com/[YOUR_ORG]/_apis/distributedtask/resourceusage?parallelismTag=Private&poolIsHosted=true&includeRunningRequests=true

The parameters are important to see all the running tasks from the hosted agents. The result contains a variable usedCount with the number of currently running jobs. However to get the details who is building what you need a second call to the details API, which comes back as a result from the first call. See here:

data.runningRequests[0].owner._links.self.href

To access the REST API you have to use BASIC auth with a dummy username and the PAT (personal access token) as the password as you can see here (I’m using the request HTTP client library to call the API).

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.

Preparation

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

/images/2019/azuresearch1_orig.jpg

Configuration

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:

/images/2019/azuresearch2_orig.jpg

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:

/images/2019/azuresearch3_orig.jpg

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.

/images/2019/azuresearch4_orig.jpg

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

/images/2019/azuresearch5_orig.jpg

TODOs

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:

/images/2018/vm-automatic-repair-failed.png

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.

Restore

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

/images/2018/vm-restore1_orig.jpg

  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.

/images/2018/vm-restore2_orig.jpg

  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.

/images/2018/vm-restore3_orig.jpg

  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 https://shell.azure.com to have a shell directly in the browser.

/images/2018/vm-restore4_orig.jpg