First look at Application Insights (Andrei Dzimchuk) - Excellent post. Perfect to make your idea about why and how we should use Application Insights. Nice touch to the config.
Cloud
Integration with Azure Service Bus (Vincent-Philippe Lauzon) - Great post that summarizes best practices and important tips related to Azure service Bus.
Get the DocumentDB SQL query cheat sheet (Aravind Ramachandran) - Confuse sometime with the syntax of noSql, this post shared a cheatsheet that should be saved (or printed).
Ghost 0.5.x from Source to Azure Web Sites (David Wesst) - If you prefer starting from the source code to deploy your Ghost blog, some steps could be less obvious. This post, the first of a series, will guide you through the deployment.
Recently I participated in a series of videos about Azure Static Web Apps: Azure Tips and Tricks: Static Web Apps on Microsoft Channel 9. The series is perfect to get started and cover multiple different scenarios in different Javascript frameworks and C#. In this post, I wanted to regroup the four videos related to .Net Blazor. I also added the GitHub links part of the references at to end.
Prevent unwanted users to access your C# API by configuring authentication and authorization in your Blazor Azure Static Web Apps.
I hope those videos will help you to get started. If you have questions and/or comments don't hesitate to reach out (comments, DM, GitHub issues), it's always a pleasure.
In this video, I wanted to show one of the great features of Azure Static Web App Learn: the creation of pre-production environments. Using the CI/CD workflow, you can preview your pull requests changes before it's in production leveraging the automatic creation of pre-production environments!
TFS Azure–Technical Access Preview Experience! (Tarun Arora) - Last week I read a post that was explaining how TFS socks. But today when I read and I see all the progress they did, I say that I would love to work with Azure TFS.
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 http://code.visualstudio.com.
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: 'clouden5srv.database.windows.net',
options: {encrypt: true, database: 'clouden5db'}
};
var connection = new Connection(config);
connection.on('connect', function(err) {
context.log("Connected");
getPerformance();
});
function getPerformance() {
request = new Request("SELECT 'Best' = MIN(FivekmTime), 'Average' = AVG(FivekmTime) FROM RunnerPerformance;", function(err) {
if (err) {
context.log(err);}
});
request.on('row', function(columns) {
_currentData.Best = columns[0].value;
_currentData.Average = columns[1].value;;
context.log(_currentData);
});
request.on('requestCompleted', function () {
saveStatistic();
});
connection.execSql(request);
}
function saveStatistic() {
request = new Request("UPDATE Statistic SET BestTime=@best, AverageTime=@average;", function(err) {
if (err) {
context.log(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) {
context.log('NULL');
} else {
context.log("Statistic Updated.");
}
});
});
connection.execSql(request);
}
context.done();
};
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 portal.azure.com 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:
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].scm.azurewebsites.net (ex: https://clouden5minutes.scm.azurewebsites.net ). Select the Debug consoleCMD. 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
BEGIN
INSERT INTO RunnerPerformance (FivekmTime)
SELECT 9+FLOOR((50-9+1)*RAND(CONVERT(VARBINARY,NEWID())));
SET @cnt = @cnt + 1;
END;
344: Exploring CoreData and CloudKit (Merge Conflict) - Honestly it felt good hearing about those two genius struggling with data. But more than that to see them continue to look for different alternatives, and try new tools and patterns. Great episode, as usual.
Learning Blazor (David Pine) - This book is just perfect! It explains a bit of everything. It is packed with real examples and code variation (because there are so many ways to write something). There was even a full chapter un test with playwright, I didn't expect that and it was great!
I'm about to start a new project and want to have it with a continuous integration (CI) and continuous deployment (CD). I've been using VSTS for a while now but didn't have the chance to try the new pipelines. If you didn't know VSTS as been rebranded/ redefined as Azure Devops. Before going in with the real thing I decided to give it a try with a simple project. This post is to relay those first steps.
Get Started
Let's start by creating our Azure Devops project. Navigate to Dev.Azure.com and if you don't already have an account create one it's free! Once you are logged-in, create a new project by clicking the New project blue button in the top right corner.
You will need to provide a unique name and a few simple information.
The Application
First thing first, we need an application. For this post, I will be using a simple Asp.Net Core site. For the repository, we have options. AzureDevOps (ADOps) support many repository: GitHub, Bitbucket, private Git and its own. Because the project I've created is public I decided to keep the code at the same place as everything else.
From the left menu, select Repos. From here if the code already exist just add a remote repository, or clone the empty one on your local machine, the usual. Create and add your code to that repository.
The Azure WebApp
The next step is to create a placeholder for our CD pipeline. We will create an empty shell of a web application in Azure with these three Azure CLI commands. You can execute them locally or from the Cloud Shell. (Don't forget to validate that you are in the good subscription)
az group create --name simplegroup --location eastus
az appservice plan create --name simpleplan --resource-group simplegroup --sku FREE
az webapp create --name simplefrankweb --resource-group simplegroup --plan simpleplan
The first command will create a Resource group. Then inside of this group we create a service plan, and finally we create a webapp to the mix.
Continuous Integration
The goal is to have the code to get to compile at every commit. From the left menubar, select Pipelines, and click the create new button. The first step is to identify where our code is, as you can see Azure DevOps is flexible and accept code from outside.
Select the exact repository.
This third step displays the YAML code that defines your pipeline. At this point, the file is not complete, but it's enough to build, we will come back to it later. Click the Add button to add the azure-pipelines.yml file at the root level of your repository.
The build pipeline is ready click the Run button to execute it for the first time. Now at every commit, the build will be triggered. To see the status of your build just on to into the build section from the left menubar.
Continuous Deployment
Great, our code gets to compile at every commit. It would be nice if the code could also be automatically deployed into our dev environment. To achieve that we need to create a Release Pipeline. And our pipeline will need artifacts. We will edit the azure-pipelines.yml to add two new tasks. You can do this directly in the online repository or just from your local machine; remember the file is at the root. Add these commands:
Those two tasks are to publish our application (package it), and make it available in our Artifact folder. To learn more about the type of command available and see example have a look the excellent documentation at: https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core. Once you are done, save and commit (and push if it was local).
From the left menubar, click on e the Pipeles, select Release, and clienk the New Release blue button. Select the template that matches your application. For this post Azure App Service deployment is the one we need.
The next thing to will be to rename the environment for something else than Stage 1, I named mine "to Azure" but it could be dev, prod or anything that make sense for you. Click on the Add an Artifact button.
You will now specify to the pipeline were to pick the artifacts it will deploy. In this case, we want the "output" of our latest build. And I renamed the Source alias as Drop.
To get our continuous deployment (CD) we need to enable that trigger by clicking on the little lightning bolt and enabled it.
The last step to configure the Release pipeline is to specify a destination. By clicking on the "1 job, 1 task" in the middle of the screen (with the little red exclamation point in a circle), that will open the window where we will do that.
Select the subscription you would like to use, and then click on the Authaurize button on the right. Once it's done go change the App Service Name. Click on it and wait 2-3 seconds you should see the app we created with our Azure CLI display. Select it, and voila!
Now add a ReadMe.md file by checking out the code on your local machine or directly in Azure DevOps. Grab a badge from the build and/or release and copy paste it in the ReadMe. To get the code snippet of your badge, go to your build/ release definition, and click the ellipse button. Select Status badge and copy the snippet that matches your destination file (in our case the Markdown).
Now when you go to the Overview page, you will have a nice badge that informed you. It also works on any web page just use the HTML snippet instead.
Every beginning of weekend, I will share a recap of the week and at the same time a summary of my streams. Those videos are at least two hour longs, so I thought a short summary to know if topic interest you could be useful. Watch only the summary or relax and enjoy the longer version that up to you!
Coding Python: Deploy Django and Postgres Apps to Azure with VS Code - c5m.ca/aaa-ep25
Stream 119 - How easy can we make the deployment of TinyBlazorAdmin - c5m.ca/stream-ep119
Stream120 - Celebrating 500 followers and working on the Chat bot - c5m.ca/stream-ep120
The Subtle Art of Not Giving a F*ck (Mark Manson) -Damn it's good! The title of the book let's me thought it will be very negative. Not giving a fu#*... But it's really not. Quite the opposite in fact. I really like the book and I'm planning to read/listen it another time in... One year. To see what changed.
Styling Social Media Icon Lists in CSS (Mark Heath) - Yeah right, we can read CSS and probably hack some stuff... But it's excellent to learn how to do simple things the good way. And this post shows exactly that.
Power BI Desktop January Feature Summary (Amanda Cofsky) - It looks like some team did not take a lot of time-off during the Holidays... So many great new functionalities; it's a fantastic way to start the year.
Designing for Big Scale in Azure (K. Dotchkoff) - Nice post that explains how we should change our design in the cloud and use logical container or scale units.
an opportunity to get application security right - Nice post discussing about in the beginning of the Internet where enterprises didn't taken seriously the security menace. Today with a lot of people going to the cloud we shouldn't make the same mistake.
Amazon Web Services Blog - Amazon announce a new free product/feature the cloudWatch Metrics that will help to visualize how your part of the cloud is use.
SSIS package needs an outbound access to port 1433
The “NoSQL” Gene in SQL Azure Federations (Cihan Biyikoglu) - Great post. A bit old, but it explain a lot of key concept about the NoSql of the new Azure Federation.
Microsoft has provided the storage credentials for the local Storage Emulator on MSDN. Here’s a quick place to copy the default name and key: AccountName AccountKey
Azure Application Architecture Guide (Mike Wasson) - A free book (pdf only) with all the best of the AzureCAT team? You really don't want to miss that opportunity.
Understanding Azure Event Grid ( Jason Roberts) - Nice little post that introduces event grid, differentiate it from the service bus, and quickly go over the pricing.
Cloud en 5 minutes (Frank Boucher) - If French is your primary language, I just start a Youtube channel where every Wednesday I will publish a new video. // Si le français est votre langue première, je viens de lancer une chaine Youtube où à chaque mercredi je publirai un nouveau vidéo.
In September, Microsoft did so many announcements it’s difficult to keep tracks of all. This short post he just to list the most important and to give you the opportunity to watch them again or the first time.
AzureCon 2015
The AzureCon was a virtual event on September 29 that was focusing on Microsoft Azure. Many View Party around the global was watching this even rich in announcements. You can watch here the AzureCon keynotes online.
But AzureCon was not only keynotes, it was more than 50 technical sessions covering every Azure’s feature. Get the the full list on Channel9 here.
Windows 10 Devices
At the beginning of October the Windows 10 Devices was a really amazing event. Microsoft was showing us all is new devices, and they were a lot! Don’t trust me, go see by yourself on this blog post by Terry Myerson.
What’s new
Get Started and deploy your first cloud solution in under 5 minutes. Find tons of short videos online that teach you how to quicky enjoy the power of Azure.
Windows Azure VM Development: Part 1 (Bryan Bolling) - Great post about how to get started working with VM in Azure. First post of a promising series.
YouTrack — Agile Issue & Project Tracker - Great tutorial that explains a steps from A to Z how install YouTrack in an Azure VM to enjoy Agile project tracking.
Announcing Amazon Elastic Transcoder - Amazon is replying to the Windows Azure Media Services that was releasing last week by announcing a service of the same kind.
Maarten Balliauw {blog} (Maarten Balliauw) - Get tutorial for continuous development. I'm looking forward to see more tools/framework from .Net that will be supported.
Azure Managed Disk–Overview (Vincent-Philippe Lauzon ) - This post is a nice quick introduction on what are managed disks.
Azure brings 5 new services to Canada (Chelsea Carter) - Good news for our clients that need to stay in Canadian Data centers, they now have a lot more tools in their box.
Deploying ARM Templates using Visual Studio Team Services (Jakob Ehn) - This post shows how to automate Azure deployments. It doesn't do it with the usual happy path, but with a very common situation where we need access Key and other information from the deployed resources to complete the deployment.
Serverless architecture with Azure - Simple Talk (Christos Matskas) - Good post that does a little tour of the serverless services in Azure.However, I would disagree on the simplistic view of Logic Apps and its limitation. Furthermore, I would have talked more about are extremely powerful these services can become if put together in a solution.
Good Monday, it's time to share new readingnotes. 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!
The suggestion of the week
Deploy Azure Static Web Apps With Bicep | LINQ to Fail (Aaron Powell) - Great tutorial that explains how to build a well-structured deployment pipeline using bicep and GitHub action. I will need this for sure, bookmarked.
ApiController Attribute in ASP.NET Core Web API (Code Maze) - This post contained many best practices and detailed explanations to get a great API and make sure the user experience is the best possible.
New Resources to Get Started with .NET MAUI - .NET Blog (Matt Soucoup) - Are you planning to learn something new this summer? I suggest you .NET MAUI, to build an application that can go everywhere. This post shares tons of references to get you started.