In the previous post I wrote an introduction to Azure Functions. That sample was created directly within the Azure Portal. That function is triggered when somebody push a picture to a blob storage and is responsible of generating thumbnails. As I told at the end of the previous post, creating, coding and testing the function directly in the Azure Portal is not an ideal solution …
I’m currently working on mac so my first challenge was to see if it’s possible to work locally in a non Windows environment and… Microsoft did it, I’m able to create, code and test locally within my mac. Kudo’s for Microsoft. (Preview)
In this page you will find all you need… In my case I’m using v2 because I need to run it on a mac. I’m gonna skip in this post the explanation about how to create the function within this tool because I won’t do it better than this doc, it’s pretty clear. To be able to use this tooling you need prior to install .net core 2 in your machine.
I’ve already a function created in the latest post, so in my case I will avoid creating it locally with this tool… instead I will download the one that I already have in Azure and I’ll execute in local to try this tool.
First step is to open the function in the portal and press the ‘Download app content’ button. Once you have downloaded the app, unzip it and open it in your favourite IDE.
You’ll find a local.settings.json file. In this file you place the configuration for example the connection string to the storage account that triggers the function.
To start the host and test locally your function:
If I push a new picture to the configured blob container that triggers this function I wil see in my terminal how the function reacts and do his stuff. Let’s see:
Now connect to the storage output container where I have configured to store the results and I see my Nicolas Cage picture thumbnail.
In the previous post I wrote directly a function in Azure and introduce the basics, in this one I have shown how to work local within Azure Functions tooling for mac, linux or windows… this allows us to put our code in a repo and work properly. In the next post I will show how to deploy this functions from your machine or from a tool like VSTS.