Azure, Azure Function Extension, Azure Functions, DotNet, Http Trigger, node.js, npm, nuget package, QR Code, QRCoder, SDK, Tip & Tricks, Visual Studio Code

Creating Azure Functions to generate QR Code

This is second post in this series, if you wish to see previous post, you can access here.

Today in this post I will discuss about first part, how to create Azure Functions.

Before we start, you need some installation to support creating Azure Functions. Use below Links to download & install these packages on the system, where you wish to write, compile & test the Azure functions.

Installation Links:

Obviously, you must have an active Azure subscription, to create an Azure Functions App. If you don’t have, you can create an account that gives you a credit to explore Microsoft Azure for 30 days.

Head to Azure portal and sign in with your account.

Create New Function App.

Select your Azure subscription and a resource group or create a new one. Provide a name for your function app. This name will be the prefix for the URL.

You can select the .NET Core runtime and the region that matches your location. Select the Review + create button.

Now, you can create new functions. A function app can contain multiple functions. Each function will be available on:

Before you start to create Function, you need to Install dependencies:

  1. You should install Visual Studio Code
  2. You should also install Node.JS 
  3. Run the following command to install the Core Tools package:

npm install -g azure-functions-core-tools@3 –unsafe-perm true

Create an Azure Functions project

Click the Create New Project… icon in the Azure: Functions panel.

You will be prompted to choose a directory for your app. Choose an empty directory.

You will then be prompted to select a language for your project. Choose dotnet.

Create a function

If you skipped to provide details, for Functions in above process, you can still initiate later.

Click the Create Function… icon in the Azure: Functions panel.

You will be prompted to choose a template for your function. Select HTTP trigger for getting started.

Screens will be same as shown in above process.

Sample project will be created

As per the information provided by you, in above screens.

KSDQRGenerator.cs auto generated file code will be as below:

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace Company.Function
    public static class KSDQRGenerator
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
            log.LogInformation("C# HTTP trigger function processed a request.");

            string name = req.Query["name"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            name = name ?? data?.name;

            string responseMessage = string.IsNullOrEmpty(name)
                ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
                : $"Hello, {name}. This HTTP triggered function executed successfully.";

            return new OkObjectResult(responseMessage);

Now you have the Http Template, we will make necessary changes as per our requirement.

In this example we will be using a library – QRCoder to generate the QR Code.

So first we have created a function with Http Trigger.

Made changes to the function as:

/*string name = req.Query["name"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            name = name ?? data?.name;

            string responseMessage = string.IsNullOrEmpty(name)
                ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
                : $"Hello, {name}. This HTTP triggered function executed successfully.";

            return new OkObjectResult(responseMessage);*/

Replace this part as below code:

            string ReqData = req.Query["ReqData"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            ReqData = ReqData ?? data?.url;
            if (string.IsNullOrEmpty(ReqData))
                return new BadRequestResult();

            var generator = ReqData;
            var payload = generator.ToString();

            using (var qrGenerator = new QRCodeGenerator())
                var qrCodeData = qrGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
                var qrCode = new PngByteQRCode(qrCodeData);
                var qrCodeAsPng = qrCode.GetGraphic(20);
                return new FileContentResult(qrCodeAsPng, "image/png");

Final Code should look like this:

There are some errors, correct. Next step will resolve the same.

Next, we will add the QRCode nuget package to the dotnet core project using 

dotnet add package QRCoder –version 1.4.1

Post completing the command execution, all errors are resolved.

Run your function project locally

Press F5 to run your function app.

The runtime will output a URL for any HTTP functions, which can be copied and run in your browser’s address bar.

Copy the URL of the function & Switch to browser:

In my case: http://localhost:7071/api/KSDQRGenerator?ReqData=Test

If you scan above QRCode, you will get ‘Test’ as we have passed this as a parameter (?ReqData=Test)

To stop debugging, press Shift + F5.

Deploy your code to Azure

Click the Deploy to Function App… () icon in the Azure: Functions panel.

Sign in to your Azure Account, if not done earlier. To test locally you need not to sign in to Azure. But at deployment is must.

When prompted to select a function app, choose KSDQRCodeGenerator (in my case), Function App Created on Azure portal in the starting of this blog post.

Confirm to deployment dialog.

On completion you will get the Live AZURE URL, use the URL in same way as for local, to pass parameter append at the end of URL as (?ReqData=Test)

Replace [Test] with the information for which you want to generate the QR Code.

That’s all for this post, but visit again to learn from upcoming posts in this series, will post soon.

See you again in next post, Till then keep exploring, learning and sharing with others.

Appointment, Development Tips, Email, How To, Information, NAV 2015, NAV 2016, NAV 2017, NAV 2018, Office 365, Office Integration, Outlook, Tip & Tricks

Programmatically Creating Outlook Appointment in Navision

Dear Friends in this post I will discuss about creating Outlook Appointment from Navision using DotNet Interop. Without going much in theory lets jump to practical approach.

To start with first we need to define some DotNet variables:

Name DataType Subtype
OutlookItemType DotNet Microsoft.Office.Interop.Outlook.OlItemType.
‘Microsoft.Office.Interop.Outlook, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’
outlookApplication DotNet Microsoft.Office.Interop.Outlook.Application.
‘Microsoft.Office.Interop.Outlook, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’
outlookApplicationClass DotNet Microsoft.Office.Interop.Outlook.ApplicationClass.
‘Microsoft.Office.Interop.Outlook, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’
outlookAppItem DotNet Microsoft.Office.Interop.Outlook.AppointmentItem.
‘Microsoft.Office.Interop.Outlook, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c’

I have created a function CreateOutlookAppointment which takes parameters as:



And the code as below:


To call this function I use below code:


The code is itself self-explanatory.

You can add other validations and parameters as per the requirement.

Imp Tip:- Make sure you set for all DotNet Variables RunOnClient = Yes.

On run the output will be as:





What you are waiting for, go create Appointment and have fun.

See you seen via my next post. Till then keep learning and growing in your career.



Data, Development Tips, How To, Information, Tip & Tricks, Web Services, XMLports

Exposing & Consuming the Web service from & inside Navision – Part-1


Today in reply to one of my reader I am giving here steps how we can Export data using XMLPort and transfer data outside Navision using Web Services.

Lets discuss about the technology before I jump to the solution.

Few full forms which may help understanding while reading this post.

W3C – Web Services Architecture Working Group.

SOAP – Simple Object Access Protocol.

REST – Representational State Transfer.

WSDL – Web Service Description Language.

UDDI – Universal Description, Discovery & Integration.

AWS – Arbitrary Web Services.

XML – Extensible Markup Language.

HTTP – Hypertext Transfer Protocol.


What is Web Service?

W3C defines Web Service as : A software system designed to support interoperable Machine-to-Machine interaction over a network.

Web service can be defined as service offered by an electronic devices to another electronic devices, which communicate with each other over www.

W3C defines web services has an interface described in a machine-process able format WSDL.

Other systems I with the web service in a manner prescribed by its description using SOAP messages, typically conveyed using HTTP with an XML serialization in conjunction with other web-related standards.

Later W3C extended the definition:-

REST – compliant web services, in which the primary purpose of the service is to manipulate representations of web resources using a uniform set of stateless operations.

Arbitrary Web Services –  the services may expose an arbitrary set of operations.


UDDI  defines which software system need to be contacted for which type of data.

Once the system is discovered to be contacted, the contact is established using SOAP.

Service provider system validate the request by referring the WSDL file, process the request and send the data using SOAP protocol.


Web Service is a method of communication that allows two software system to exchange the data over the internet.

  • Two systems may use different software which could be using different programming languages.
  • Almost all type of software interpret XML tags.
  • Web Services can be used to exchange data between two systems in form XML files.


XML is used to tag the data.

SOAP is used to transfer the data.

WSDL is used to describe the services available.

UDDI lists what service are available.

Human to machine communication is utilized for machine-to-machine communication, used for transferring machine readable files such as XML & JSON formats.

Web services use SOAP over HTTP protocol, facilitating to use your existing low-cost internet for implementing Web Service.

Rules for communication between two different systems:

All the rules are defined in WSDL file.

  • How request to be send from one system to another.
  • What all parameters need to be send while requesting data.
  • What structure to be used for generating data (Normally data is exchanged in XML format) which is validated against .xsd file.
  • What errors to be generated in case of failure of rule communication set.


Web Services that uses Markup Language:

  • Web template
  • Web Service Description Language (WSDL)
  • XML Interface for Network Services (XINS)
  • Web Services Conversation Language (WSCL)
  • Web Services Flow Language (WSFL)
  • WS-Meta data Exchange
  • Representational State Transfer (REST)
  • Remote Procedure Call (RPC)
  • XML Remote Procedure Call (XML-RPC)


No more theories lets come to our point.

There are other ways too to achieve the same, but here I am specific to the requirement to which I am answering.

Requirement is the Data in XML format file will be transmitted using Web Service, We will be using Navision Exposed Web Service to Export data using XMLPort and then send the content by consuming another Web Service exposed in Dot Net which will retrieve the XML content and update in some other system.

Assumption is these two endpoints can be two separate databases in same domain or two different companies of same organization operating at two different location sharing information via Web Services.

For the demo purpose I will be using Navision to publish the service for exporting the data and retrieve the data using Web Service exposed in Dot Net.

Since I have not in depth knowledge of Dot Net codes, so I have asked my college to prepare the Web Service for me and I am simply using it to show how we can do it.

Here I will be getting this done through below 5 Steps.


Next Post in this Series will contain:

Step 1: Create a XML Port to Export Data in XML Format using XMLPort and save at some specified Location.

Step 2: Create a Codeunit to call XML Port and retrieve data in XML Format in Text Variable.

Step 3: Expose/Publish the Codeunit as web service.


Next Post in this Series will contain:

Step 4: Create a DLL to use as Add-in to consume the Web Service itself in Navision.


And the Final Post in this Series will contain:

Step 5: Create a Codeunit to test Retrieve the data using above DLL and Send data in XML Format using another Web Service exposed in Dot Net.


Please follow my upcoming post for Walkthrough to get above 5 steps done.

To Be Continued……….