In this blog post, let us look at how to provision an Azure Function in Visual Studio and publish to the Azure portal. In addition, this blog also covers how to integrate the published Azure Function to a project in Microsoft Flow. It is a continuation of the Whitepaper – How to extract email attachment with Microsoft Flow.
- Visual Studio 2017 V15 or above
- Azure Subscription
Let us start with Provisioning a Function in Visual Studio
- Provisioning Function App in Visual Studio
- Open Visual Studio and go to File-> New-> Project
- In the New Project window, Select Azure Functions under visual C#
- Fill the Name field with custom name “checkIfSignaturePicture” and Click OKClick Ok
- In the new window that pop-up, select Run-Time version as “v2” and the trigger as “HTTP trigger” and Click Ok
Now, a new project would have created with some default sample code in it.
- Replace the default code
- Delete the existing default code and paste the below mentioned code. This plays a vital role in determining the signature picture and the actual attachment.
- You need to add the HtmlAgilityPack library to initialize HtmlDocument class which is used to retrieve the content of the img tag.
- The Function returns Boolean value based on the image depicted.
public static class checkIfSignaturePicture
public static async Task<bool> Run(HttpRequestMessage req, ILogger log)
bool isSignature = false;
string jsonContent = await req.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonContent);
HtmlDocument htmlDoc = new HtmlDocument();
var htmlNodes = htmlDoc.DocumentNode.SelectNodes("//img");
foreach (var node in htmlNodes)
isSignature = true;
catch (Exception ex)
- Right Click on the project name which you can find on the right side of the screen and select publish
- In the new window which appear, select “Create New” option and hit Publish
- A new window would appear now with set of options, select the appropriate subscription, resource group and click Create
- Now, you should see the publish process that has been started
- Lastly, push “Publish” button to publish the Function App to the Azure portal
Now, head to the Azure portal and follow the steps described below;
- Login in with your Azure Subscription account
- Click on the Function App in the left navigation bar
- The new window that appears may contain the list of Function App name. Select the right App that you have published from the Visual Studio, checkIfSignaturePicture.
- Click on the appropriate App and you will be navigated to a new window
- Select the function inside the Function App from the left navigation bar
- You can now see the function is in read-only mode as it is published from Visual Studio
- Now, copy the function URL or endpoint from “Get function URL”
Integrate the Function with Microsoft Flow
Head to the Microsoft Flow project and paste the copied Function URL or endpoint in the HTTP request action under URI field. The HTTP action uses this endpoint to send the parameters to the function in the portal and in return sends a response.
In this blog, we have seen how to provision an Azure function in Visual Studio and Publish to the Azure Portal. Also, on integrating the Function in portal with Microsoft flow.