Microsoft Build 2018 – Session Recommendations (Part 2)

As promised, I bring a couple more sessions from Microsoft Build 2018!

The first part of this list can be found here.

Be aware that I’m a .NET+C# Lover, so those are the sessions that I enjoy the most, but if you want a deeper look into the sessions catalog, you can go through this list on Channel9, all the sessions are there (or will be very soon)

But let’s start with my session recommendations.

.NET Overview & Roadmap

This session was amazing. Presented by Scott Hanselman and Scott Hunter, it presented some amazing numbers about .NET Core and how bright (and fast) the future will be.

They also presented a couple of ideas that they are working on and I was particularly AMAZED by the demo on the micro-services template that they are playing with for ASP.NET Core 2.2. You will see that the session’s audience reaction was also very positive.


Also great demos on .NET Tooling and Blazor (Blazor is unbelievable so far)

I, particularly, loved it. Also, Scott Hanselman was joking as hell on this one, it’s almost half tech half stand-up comedy 😛 

The session:

Pair Programming Made Awesome with Visual Studio Live Share

I tried really hard to get access to VS Live Share during the Beta phase, but unfortunately it didn’t work out for me, now it really available (in preview) and it’s awesome!

The whole idea is to be able to share code files during a LIVE session in a way that developers can collaborate and help solve each others problems (or any other idea that you can come up in a collaboration session)

But how is it different from Screen Sharing? Well, it has a number of benefits that are enumerated on this session by Jonathan Carter and Jon Chu.

I played with it a little bit with some friends (even friends from Brazil!) and it really is super fun.

Past, Present, and Future of .NET

I did a post not long ago about a session from Richard Campbell on the history of .NET, which was really great. If you watched it you might know that he is now working on a book about the History of .NET (!)

Now, in this Build 2018 Talk/Session, he is exploring some of this history with some major players from the .NET world! Scott Hunter, Beth Massi and Mads Torgersen.

This is really just a casual talk exploring some of the major events that led to the current state of the platform. It’s really nice to see how things played to get us to where we are right now.

The player is a bit different on this one because it’s straight out of Channel9 and not from YouTube.

Technology Keynote: Microsoft Azure

Also traditional at this point is the Microsoft Azure Technology Keynote by Scott Guthrie.

Again there was a big focus on the AI power that Microsoft is adding to the Azure Cloud every day. This one has a number of really interesting demos!

  • Visual Studio Live Share (Amanda Silver & Johnathan Carter)
    • I’m really super excited about this feature! So much potential.
  • VS App Center + GitHub Integration (Simina Pasat)
  • VSTS and a Lot on CI/CD (Donovan Brown)
    • I consume a lot of CI/CD and DevOps resources at my work, but I’m not really a specialist in configuring or maintaining them, still, this Demo made me want to now a lot more about it!
  • Kubernetes + Azure + Visual Studio (Scott Hanselman)
    • Nice Demo on how those 3 tools integrate really well to make the handling of containers with Kubernetes on Azure be as smooth as possible.
    • There was a funny technical problem during this Demo 😛 Scott Guthrie added some value to the presentation.
  • Serverless + IoT (Jeff Hollan)
    • I don’t need to tell you how much Microsoft is investing on this right? Azure Functions are getting better and better in an amazing speed.
  • CosmosDB (Rimma Nehme)
  • Azure Search + Cognitive Skills (Paige Bailey)
  • Azure DataBricks (Paige Bailey)

As you can see there was two Demos by Paige Bailey, a Cloud Developer Advocate for Azure that has a number of amazing posts on twitter! You can follow her here.

And here is the session.

Nice wasn’t it? 😀

I have enough videos on my queue yet, so I will probably make at least one more post with more session recommendations. Let me know if you are enjoying it!

Microsoft Build 2018 – Session Recommendations (Part 1)

As some of you might know, the Microsoft Build 2018 event happened this week (07-09 May) and this is always an awesome event for .NET Developers!

As I am making my way through as many sessions as my time allows me, I would like to share some of the best ones (in my not so humble opinion) with all of you!

Vision Keynote

I will start here with the more obvious one, the Keynote from Satya Nadella. This year’s Vision Keynote focused a lot into AI in the Cloud (Intelligent Cloud) and AI in IoT (Intelligent Edge), which is pretty interesting as I still lack a lot of experience in both AI/ML and IoT.

This Keynote actually made me very excited with what Microsoft envisions for AI and Machine Learning in the .NET world for the future, and I will try to keep my radar on this subjects.

I am particularly excited with ML.NET and the ever-growing power of the Cognitive Services.

As usual, there are some amazing numbers about the industry:Industry Numbers

Here is the video:

The Future of C#

This session is a must for me by now, as every year Mads Torgersen and Dustin Campbell make an awesome presentation on what is coming next for my favorite language ever. (I love you Python, but C# comes first)

I was a bit disconnected from what is about to come with C# 8.0 and this session was amazing to put me up to speed with the stage in which those feature proposals are.

If you wanna know more about C# language feature proposals (or maybe even propose your own!) you can check this repository on github.


MACHINE LEARNING IN DOTNET! Do I need to say anything else? Okay, a bit more then:

  • It’s multi-platform (Windows, Linux and MacOS)
  • It’s Open Source (check it out here)
  • It’s still on Preview

The session is a really short one (20 minutes) and in this short time Rowan Miller walks through an application that can fix a piece of music(!) using Machine Learning with ML.NET.

It’s a relatively high altitude overview of the Framework’s capabilities, but it’s also super FUN, and powerful.

I am still waiting for them to upload some sessions that look really amazing.

But what do you think of these sessions so far?

I will post another list of my favorite sessions in a couple of days, after I went through most of my watch list 😛

Talk to you soon 🙂

Azure Web Jobs – Creating your first Azure Web Job from Scratch

So, you have just created your first Web App in Azure, and it is working like a charm. You have all the scalability you need and you know exactly how to store your data in the many options that Azure provide. What else do you need? Well, what will you do if you need to run some asynchronous background processing, like processing images or batch data? That is when Azure Web Jobs comes in handy.

What are Azure Web Jobs?

Straight from Azure documentation web site:

WebJobs is a feature of Azure App Service that enables you to run a program or script in the same context as a web app, API app, or mobile app. The purpose of the WebJobs SDK is to simplify the code you write for common tasks that a WebJob can perform, such as image processing, queue processing, RSS aggregation, file maintenance, and sending emails.

So, as you can see, it can perfectly fit the role of asynchronous background processing and with one interesting advantage, Web Jobs have very powerful integration with other Azure Services like the Service Bus and the Storage Services, making it incredibly easy not only to read/write data to this services but also to use them as TRIGGERS, avoiding the use of scheduled processing.

Let’s begin.

Creating your first ‘Azure Web Job’ from Scratch

The idea here is to create a simple Web Job that will be triggered after an item is added to an Azure Queue, and after very little parsing, save it to the Azure Tables Service.

The Setup

The first thing we are going to need is an Azure Account. If you don’t already have one, you can create one here, for free. Then we will install the Azure CLI 2.0, the installation instructions for all platforms can be found here. You may also want to install the Azure Storage Explorer, a tool that we will use to manage our Storage Account for testing.

Now we need to setup the resources in Azure to which the Web Job will connect. I’ll give you a list of commands from the Azure CLI that must be execute in a shell prompt.

First things first, we need to login to Azure through the console.

Then we need to create the Resource Group that will group all our resources.

Storage Account

Next step, create the storage account.

Then we create the Queue, that will be the source for our data, and the Table, which will be the destination of the processed data.

That’s all we need in the Storage service. Now we need to create the App that will host our Web Jobs.

App Service

And last, but not least, let’s configure our Connection Strings for the App:

And that is it for the Setup. Now, we can begin the coding.

Finally! Web Jobs

The Coding

For the coding part we can use whatever code editor we prefer. I will use Visual Studio Code, as it offers great support for coding C#.

As for the programming language, you may be surprised to know that Azure supports a lot of programming/scripting languages in the Web Jobs SDK, so you can choose the one you like the most. For this exercise, I will use C# because I feel like doing so 🙂

Start the Project

As I want this article to be as multi platform as possible, I will create a new project using the dotnet CLI. Open a shell prompt, navigate to the directory of your Web Job and type the following command:

Unfortunately the Web Jobs SDK has no support yet for the .NET Core Framework, so we have to make a small modification to the .csproj file, so we can use .NET Framework v4.5x.

The final file should look like this:

It is important to understand that a .NET Core Application can be executed by a Web Job, it only cannot make use of the Web Jobs SDK, which makes it much easier to integrate with other Azure Services

Azure Web Jobs SDK

Back to the shell prompt, we need to do three things. Add the Web Jobs SDK Package, restore the packages and build the project.

Code Host

It is worth mentioning now that one Web Job project has, at least, two main components:

  • The Code Host
    • This is the Entrypoint for the application, and this is where we should do all the configuration for our Web Job
  • A Trigger
    • Our project must have at least one Trigger, but it can have many others. In this case we will use only one trigger, fired by a new entry in our Queue.

Let’s start with the Code Host, which will be placed in the Main method of our code and will be the starting point of the application

That’s it 😀

Seriously Web Jobs?

No! I am not. The Host is, as the name implies, a piece of code that will configure your web job and control the lifetime of the code. It can be a lot bigger than this, including all sorts of configurations, but that is all we need for a simple Web Job.

The Trigger

The trigger is where the real business logic of our Web Job live or, at least, where it begin. In our case we will have a single method that takes a QueueTrigger and records the data to a Table. The table will also be represented through a parameter, to which we will save the data.

This is the method code:

Simple enough, isn’t it?

The method gets three parameters, the first one is the trigger itself, the message in the queue, notice that the attribute of the parameter specifies which queue the message comes from. The second parameter has the “out” keyword, specifying that is the output of the code and the parameter attribute also specifies the Table to which the data must go. The last parameter is a TextWriter object that the Azure SDK injects so you can log information to the Azure Log Console.

The model for the Queue is a simple POCO class, nothing special about it. The model for the Table inherits from “TableEntity” making it suitable to be saved to an Azure Table.

We are almost there! Only one step missing!

Deploy Web Jobs!

The Deploy

Now we have to deploy our Web Job to Azure, which is actually pretty simple. First thing we want to do is to build the project, to make sure that everything is in place, back to the shell prompt!

We should get a result like this:

Deploy Web Jobs

Navigate to the directory showed in the build command, in my case C:\Code\AzureCoderWebJob\bin\Debug\net45\, then we will zip the content of the folder.

Zipped Web Job

Now you have to open the Azure Portal, and login with your account.

In the Dashboard page, look for the App Service you created during the setup and open it. In the App Service Blade, under “Settings”, look for the option “WebJobs” and click on it, the WebJobs Blade will be opened, and at the top you should see a button “Add”, click on it. The Blade to add a new WebJob will be opened, and we will have to fill some information:

Add Web Job

The name is simply an identifier for the WebJob, the File must be the Zip file we have just created.

The possible “Type”s are “Continuous” and “Triggered”, it may cause a little confusion but we want to keep the Continuous Type.

The scale is what define if the WebJob will run in only one instance of the App Service or in all the instances, scaling with the Web App, it is not so relevant for our WebJob, so we will keep the default “Multi-instance”.

After filling all the fields, click in “OK”, wait for the deployment and process and… that’s it 🙂 You have just deployed your first WebJob created from scratch! But, how can we test it?

The Test

Let’s start by opening the “Logs” for our deployed WebJob. After we deployed the WebJob, we will be sent back to the WebJobs list Blade. In this list, select the WebJob and click in “Logs”. The Logs will be opened in another Tab of the Web Browser. We should see something like this:

Web Jobs Logs

Click on the title of the Web Job and you should see a small console, with the execution details for the Web Job:

Web Jobs Log

As you can see, our “ProcessQueue” method has been detected!

Now we must add a new item to the azure-coder-queue, using the Azure Storage Explorer…

…and then look at the log again:

Log Web Jobs

Our message has been successfully processed! Now, if we take a look at the contents of the AzureCoderTable, also using Azure Storage Explorer, we should see our item added to the table:

Web Jobs Table

Happy Web Job

And, finally, that is all you need to know to create a very simple WebJob from scratch! Most of what I showned here should work fine in Linux and Mac OS (apart from the usage of .NET Framework) but, unfortunatly, I am not able to test every step in these platforms, so let me know if you try and have any problem!

I am really sorry for the long post 🙂

Long Web Job Post



[Azure Functions] Function wide Log Service

I confess, I am log-addicted. If I have to guess I would say that at least 1/3 of my code are log calls. It despairs me to look at a console and don’t know exactly what is going on.

That said, Azure Functions provides a very simple-to-use system to log to the execution console. You just have to add a TraceWriter object as a parameter for the Run method.

Couldn’t be easier, I think. But when your function is a little more complex than that you will probably have some separated code files for your business logic (I hope, for the sake of you sanity) and that is when it becomes a little complicated to log your processing.

The obvious choice is to pass the TraceWriter object around through all your methods and simply use it.

It really can be a viable solution if we are talking about two or three methods, but it will be a real mess if you have more than this.

So, I came up with a solution that worked really well for me 😀
The solutions consists of initializing a global object at the beginning of the Function that will be used throughout the code, just importing the Service code file.

The Service code file can be found here. It is really a just simple piece of code. To use it, you just have to instanciate the object at the beginning of the function Execution:

The Log object in line 6 is global and static and is defined in the LogService.csx file. The LogService class is also defined in the same file.

And then you can use it anywhere in the code, just referencing the Service code file

How does it look? 🙂

Connecting to SharePoint in Azure Functions using App Only Permissions

So, recently I needed to create a service that would read and write some data to SharePoint Online, easy enough, isn’t it? Problem was that the scenario demanded that the processing were done in Azure, specifically in Azure Functions. Hmmm… How difficult can it be? (Well, it has to do with SharePoint, so…)

The first thing I did was to import the usual packages that I use to connect to SharePoint:

Both packages had worked perfectly in all previous scenarios, then I had no reason to not try it.

Problem was that the version that the runtime downloaded didn’t have an option for obtaining an App Only Authorization Token, which was necessary in my case.

So, cutting to the chase, after some struggle I found a version of TokenHelper.cs that had the methods that I needed and then I’ve been able to successfully convert it to .csx. The file is available in the following link:


This file will allow you to connect to SharePoint Online using App-Only Authorization like this:

This is as simple as it gets 😀

I hope this helps anyone who is starting with Azure Functions and SharePoint!