Category Archives

Writing, writing, writing…

.NET, Azure, Azure Functions, Cloud Developer Advocate, Microsoft, Technical stuff, Work, Xamarin
No Comments

One thing I love in my new job is that I can just sit down anywhere on Earth, grab my Surface Pro and produce content (articles, samples, etc) or learn new things just as if I was home. I just came back from Singapore and had a great time there talking at the Xamarin “MonkeyFest” conference. But it was also a busy time producing content and I am so happy that things are starting to fall into place.

Here are a few highlights:

  • I just published a few new articles (see below). As I am discovering new features of Azure, I want to share with you all. I decided to write in markdown (just like docs.microsoft.com) and publish on GitHub. Why GitHub? Well first of all this is of course the destination for developers. The markdown renderer is pretty good, it is easy and fast to create and publish good quality content. At some point this documentation might migrate to another location, but for now it makes sense to have it on Github. Also, and maybe most importantly, I like that the source code and the corresponding articles are all grouped together, for example my sample-azure-coinvalue application.
  • As I was writing, I noticed that a few topics are going to be recurrent in all my samples. So I went ahead and created the following repo: sample-azure-general. In this repo, I will document recurring processes in Azure, such as creating a trial account, Creating and testing Azure Functions in Visual Studio, Publishing functions to Azure, etc etc etc.
  • In parallel I am also working on new samples and should be able to publish more soon. So stay tuned to this blog or to my Twitter account. Yes for now the list of samples is very lean but now that everything is starting to be coherent, I want to add new content regularly!

Please help me help you!

I’d really like you all to be able to tell me what is the most important for you. And so in this spirit I want to start with two features:

Available articles:

At the moment you can find the following content in sample-azure-general:

Hopefully this is helpful to all of you, and I hope that we can get the discussion running. Microsoft is literally paying me to help you understand Azure, cross-platform, Windows, .NET and more and I love that job. So please please please don’t be shy and let me know what you need. We want to help!

Happy coding
Laurent

GalaSoft Laurent Bugnion
Laurent Bugnion (GalaSoft)
Share on Facebook

My talks in September

.NET, Azure, Azure Functions, Microsoft, MVVM, Work, Xamarin
No Comments

I don’t know about you but I had an amazing summer. I had the amazing luck of spending time in beautiful places in the Philippines, Iceland and then 2 great weeks in Seattle and Redmond. Having started to work with Microsoft on August 1st, it was great to be on campus in Redmond as a blue badge.

Apart from sitting down with my new team, meeting my new manager and old friends on campus, I also delivered two sessions at the Visual Studio Live conference. The event took place at the Microsoft conference center (Building 33) and was as packed as usual with great speakers and very competent attendees. This year was special for me because my two talks took place in the Cascade room, which is a really nice auditorium with all the comfort. I also had a lovely time interacting with attendees at the traditional Birds of a Feather lunch, where a table is assigned to a speaker and attendees can go around the room, sit down, ask questions or just chat.

You can find the slides, source code and all the information about my two talks on my website:

Amsterdam: MVVM Cross Hackfest

My next engagement is the closing event of the MVVM Cross Hackfest taking place in Amsterdam on September 2nd. The .NET Open Source foundation is sponsoring this event with others, where the aim is to encourage new contributors to help open source projects. For MVVM Cross, the event is the occasion to port this popular framework to .NET Standard. While the project lasts 2 weeks, September 2 will be the last day with a celebration, some lightning talks and a party.

At this occasion, I will speak about Azure Functions (which are really awesome). My Microsoft colleague Mike James will also be there and speak about other Azure services. The rest of the lightning talks will be held by MVVM Cross contributors. You can see the program here. My session’s abstract is the following:

Azure Functions and Xamarin

One of the most exciting recent additions to Microsoft Azure is called Functions and allows the developer to quickly build and deploy code to the cloud without complicated setup. Also dubbed “serverless computing”, Azure Functions can be triggered by timers, HTTP calls or database operations, and can communicate with other Azure services or mobile and desktop applications such as those made with Xamarin. In this lightning talk, Laurent Bugnion, Cloud Developer Advocate for Microsoft, will give you an introduction to Azure Functions and get you started with this exciting aspect of modern computing.

Singapore: MonkeyFest

A little later in the month, I will fly to Singapore to attend the MonkeyFest conference which is a Xamarin event organized for the first time in the beautiful south east Asian city. There is a nice team of speakers speaking on a variety of topics. The entrance tickets can be purchased for 19 Singapore dollars, which is very cheap for such a quality show! We hope to see a lot of attendees at Microsoft Singapore!

Building truly Universal applications with Windows, Xamarin, MVVM and Azure

With Windows 10 supporting an unprecedented number of platforms and form factors (from IOT to phones to tablets to laptops and desktops to XBOX and SurfaceHub, and even the new HoloGraphic computer HoloLens), the name “Windows 10 Universal application” is fairly accurate. But to be honest, shouldn’t a truly Universal application run on Windows 7, iOS and Android devices too? Thankfully, this is possible thanks to a clever architecture pattern named Model-View-ViewModel, the .NET portable class libraries and the Xamarin frameworks. With these tools, we can structure an application so that most of the code is shared across all the platforms, and then build truly native UI that adapts without any compromises to the device it runs on. In this session, we will understand exactly how such universal applications are built. Laurent Bugnion, a XAML/C# expert, Microsoft and Xamarin MVP who started making universal applications before it was even a thing, will show you practical knowledge with a lot of demos. Come listen from the creator of the popular MVVM Light Toolkit how this powerful but simple library can be leveraged to help you target more users than you ever dreamed of!

Come say hi!

I hope that I will have the occasion to see a lot of you out there. I have more talks coming up in November – but that is for another post. Please come say hi!

Happy coding
Laurent

GalaSoft Laurent Bugnion
Laurent Bugnion (GalaSoft)

Share on Facebook

Running unit tests on Azure Functions in Visual Studio 2017

.NET, Azure, Azure Functions, Microsoft, Technical stuff, Visual Studio
No Comments

TL;DR; You should really update your Nuget packages

I am currently experimenting a lot with Azure due to my new job and also of course due to the really cool innovation that we can find there. Recently I got interested in Azure Functions. This cool feature allows to write a small piece of code that runs on Azure and can be triggered by various events (time based, HTTP-request based, etc). For example, imagine that you have a value that keeps changing and you want to monitor this value and do some kind of analytics on this. In the code I am currently writing, I am using the value of a Bitcoin as the sample, and I am just periodically reading this value and storing it into an Azure database.

For this small functionality, it would be much too complicated to set an entire server-based application up. This is a perfect example for a time-based Azure Function. I am not going to explain more about Azure Functions here, because I am working on a complete article including sample which will do that. But in the course of my investigation, I stumbled upon an issue that can easily be solved.

The problem:

The issue arises when you try to write unit tests for your Azure Function. In many examples I saw, the Azure Function was created straight in the Azure portal, which is great but makes it a bit difficult to unit test the code. Thankfully it is also possible to create the Function project in Visual Studio, and to take advantage of all the features including unit test, code coverage etc.

To do this, try the following:

  • Install Visual Studio 2017. I currently have the Update 3, which is the most recent at this time. Make sure to select the Azure workload when you install Visual Studio!

Click to see the full picture

  • In Visual Studio, select Create new project.
  • In the New project dialog, select Cloud on the left, and then Azure Functions.
  • Give your project a name and then click OK.
  • Right click on the Function project and select Add, New Item.
  • In the Solution Explorer, right click on the solution and select Add, New Project.
  • In the Add New Project dialog, select the Test category, and then Unit Test Project (.NET Framework).
  • Give your unit test project a name and then click OK.
  • In the Unit test project in Solution Explorer, right click the References folder and select Add Reference.
  • In the Reference Manager dialog, select Projects and then the Function project that you created earlier. Then click OK.
  • Build the solution.

If you have the same setup as I have, you will get an error stating something like:

Metadata file ‘C:\Users\Laurent\Documents\Visual Studio 2017\Projects\FunctionApp2\FunctionApp2\bin\Debug\net461\FunctionApp2.dll’ could not be found

Indeed, if you check the path in Windows Explorer, you will see that there are no DLLs under FunctionApp2\bin\Debug\net461. There is however a folder under FunctionApp2\bin\Debug\net461\bin which contains all the DLLs. The issue is that the Functions project does not generate its output to a standard path. As a result, the Unit test project does not find the reference it was expecting.

The resolution

After reaching out to the Azure Functions team, I found out that this is a know issue and that an updated project template for Visual Studio will be released soon. But there is already an easy fix that you can apply to your project today: You just need to update your Nuget packages, and this will apply the fix to the Functions project.

  • In the Solution Explorer, right click on the Solution and select Manage Nuget Packages for Solution.
  • Under Installed, select the Microsoft.NET.Sdk.Functions package.
  • On the right under Versions, select the Function project. Note that the version shown is smaller than 1.0.2 (likely 1.0.0).
  • Below this box, make sure that Latest stable 1.0.2 is selected in the Version combo box and then click Install.
  • Build the project again. This time it should succeed.

Click to see the full picture

Conclusion

This was an easy fix that the Azure Functions team was able to deploy to your project using an update to the Nuget package. Of course, there are good reasons why teams are sometimes reluctant to apply an update: They might fear that the update brings breaking changes, or that something might go wrong unexpectedly due to regression bugs etc. But when you create a brand new project, it is a good idea to apply the Nuget updates to the solution. This way you will make sure that your new project starts with the latest and greatest.

Thanks to the Azure Functions team for their help solving this issue!

Happy coding
Laurent

GalaSoft Laurent Bugnion
Laurent Bugnion (GalaSoft)
Share on Facebook