{"id":112,"date":"2019-05-29T19:21:07","date_gmt":"2019-05-29T19:21:07","guid":{"rendered":"http:\/\/yer.ac\/blog\/?p=112"},"modified":"2019-05-29T19:52:13","modified_gmt":"2019-05-29T19:52:13","slug":"remote-nlog-logging-with-azure-functions-part-one","status":"publish","type":"post","link":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/","title":{"rendered":"Remote NLOG logging with Azure Functions (Part one)."},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Part of a journey I was on today to learn about Azure Functions and Cosmos DB.  The final code for the Azure Functions element can be found on <a href=\"https:\/\/github.com\/Wabbbit\/AzLog\">https:\/\/github.com\/Wabbbit\/AzLog<\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Part one: Setup, Creating my first function, forwarding NLOG events and deploying to Azure within VS Code.<\/li><li><a href=\"http:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-two-persisting-data-into-azure-cosmos-db\/\">Part two<\/a>: persisting the incoming data using Cosmos DB.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Disclaimer:<\/strong> This blog is more like my mental notes, this tech is super fresh to me so take with a pinch of salt. \n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What I want to achieve<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Logging is a necessity in any application, I can&#8217;t even count the amount of times having some verbose logging has saved me many hours of debugging.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Currently, I almost exclusively use <strong><a href=\"https:\/\/nlog-project.org\/\">NLOG<\/a><\/strong> for .net projects. I typically structure my logging into discrete, separate loggers (i.e. Startup, API, Business logic failures, etc), which are usually configured to dump into .txt and\/or the system event log.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is great for our internal dev\/SIT\/QAT machines, and also when a client rings up about an error they encounter as they can just provide the appropriate log. The downside of this of course is that we don&#8217;t know if a client (With a self-hosted, remote installation) has a fatal error until they contact us, and with some clients the chain of reporting means the system could have been impacted for a short while before we get notified.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>What if we could remotely capture major errors? <\/strong>As a proof of concept I will be attempting to use the NLOG web service adapter to talk to a C# Azure Function. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This assumes previous knowledge of working with NLOG and C#, but not Azure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating my first Azure Function.<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Prerequisites <\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Azure functions can be created directly within the Azure Portal, but for this demo I will be using VS Code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First we need to make sure the system is set up to work with Azure Functions.  We will need the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>VS Code<\/li><li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-functions\/functions-run-local#v2\">Azure Functions Core Tools<\/a>: For this we can use NPM. <code>npm install -g azure-functions-core-tools<\/code>.  Note that this also exists on choco but <a href=\"https:\/\/stackoverflow.com\/a\/55120037\">has issues<\/a> with x64 debugging in vscode.<\/li><li>Azure Functions VS Code <a href=\"vscode:extension\/ms-azuretools.vscode-azurefunctions\">extension<\/a>. <\/li><li>C# VS Code <a href=\"vscode:extension\/ms-vscode.csharp\">extension<\/a>.<\/li><li>and later on, an Azure account so we can deploy<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Lets make a function!<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">With the Azure Functions extension installed, select the Azure menu and then &#8220;Create new project&#8221;. <strong>Don&#8217;t worry about connecting to your Azure subscription yet if you have not done so.<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"353\" height=\"331\" data-attachment-id=\"119\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/image-4-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png?fit=353%2C331&amp;ssl=1\" data-orig-size=\"353,331\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-4\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png?fit=353%2C331&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png?resize=353%2C331\" alt=\"\" class=\"wp-image-119\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png?w=353&amp;ssl=1 353w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png?resize=300%2C281&amp;ssl=1 300w\" sizes=\"auto, (max-width: 353px) 100vw, 353px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Once a folder is specified, a language must be chosen. I chose C#.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"604\" height=\"120\" data-attachment-id=\"121\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/image-5-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-5.png?fit=604%2C120&amp;ssl=1\" data-orig-size=\"604,120\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-5\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-5.png?fit=604%2C120&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-5.png?resize=604%2C120\" alt=\"\" class=\"wp-image-121\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-5.png?w=604&amp;ssl=1 604w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-5.png?resize=300%2C60&amp;ssl=1 300w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Next, the template for the first function will need to be specified. For this demo I will be using the <strong>HttpTrigger<\/strong> which means it will fire when hit on receipt of HTTP Get or Post (Like any standard API)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"609\" height=\"128\" data-attachment-id=\"122\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/image-6-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-6.png?fit=609%2C128&amp;ssl=1\" data-orig-size=\"609,128\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-6\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-6.png?fit=609%2C128&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-6.png?resize=609%2C128\" alt=\"\" class=\"wp-image-122\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-6.png?w=609&amp;ssl=1 609w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-6.png?resize=300%2C63&amp;ssl=1 300w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The next panel will ask for a function name. For this I just chose &#8220;Log&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A new Azure Function will be created. Lets take a look at the files that are created:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>.vscode: All the standard VS Code items which assist in build, debug and required extensions.<\/li><li>*.csproj: The project file for this Azure Function.<\/li><li>&lt;function-name&gt;.cs : This is the function that was created by providing a name in the last dialog. This is essentially like a Web API Controller.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Pressing F5 should restore any packages, start a debug session and output the temporary URL into the terminal, like so:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"664\" height=\"283\" data-attachment-id=\"123\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/image-7-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-7.png?fit=664%2C283&amp;ssl=1\" data-orig-size=\"664,283\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-7\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-7.png?fit=664%2C283&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-7.png?resize=664%2C283\" alt=\"\" class=\"wp-image-123\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-7.png?w=664&amp;ssl=1 664w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-7.png?resize=300%2C128&amp;ssl=1 300w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Navigating to that URL with a browser or postman will render something like:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"374\" height=\"68\" data-attachment-id=\"125\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/image-8-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-8.png?fit=374%2C68&amp;ssl=1\" data-orig-size=\"374,68\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-8\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-8.png?fit=374%2C68&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-8.png?resize=374%2C68\" alt=\"\" class=\"wp-image-125\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-8.png?w=374&amp;ssl=1 374w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-8.png?resize=300%2C55&amp;ssl=1 300w\" sizes=\"auto, (max-width: 374px) 100vw, 374px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Hooking up NLOG WebService target<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now I have a base function (Even if it doesn&#8217;t do anything), I can update NLOG in my project to make a web request with some information. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my <strong>NLOG.config<\/strong>, I need to add a new target between the &lt;targets&gt;&lt;\/targets&gt;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;target type='WebService'\n            name='azurelogger'\n            url='http:\/\/localhost:7071\/api\/Log'\n            protocol='HttpPost'\n            encoding='UTF-8'   >\n      &lt;parameter name='timestamp' type='System.String' layout='${longdate}'\/>\n      &lt;parameter name='loggerName' type='System.String' layout='${logger}'\/>\n      &lt;parameter name='loggerLevel' type='System.String' layout='${level}'\/>\n      &lt;parameter name='message' type='System.String' layout='${message}'\/>\n    &lt;\/target><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">What we have done here is:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Create a new NLOG target of type &#8220;Web Service&#8221; to the URL from the step previously.<\/li><li>Set up a few parameters to send across with our request, which are NLOG parameters for things like the log message, the time the entry was created, etc.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Now I need to ensure that one of the loggers is set to use the new &#8220;azurelogger&#8221;. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;rules>   \n  &lt;logger name=\"StartupLogger\" minlevel=\"Error\" writeTo=\"event, azurelogger\" \/>\n&lt;\/rules><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now if I do an IIS Reset where my NLOG  config lives, and trigger off an error message manually, the new Azure Function should receive all the information it requires.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>However,<\/strong> as our function doesn&#8217;t *do* anything, we can only prove this by debugging the function in VS Code. To do this I placed a breakpoint within the function and inspected the <code>req<\/code> object.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"636\" height=\"401\" data-attachment-id=\"133\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/image-9-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-9.png?fit=636%2C401&amp;ssl=1\" data-orig-size=\"636,401\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-9\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-9.png?fit=636%2C401&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-9.png?resize=636%2C401\" alt=\"\" class=\"wp-image-133\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-9.png?w=636&amp;ssl=1 636w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-9.png?resize=300%2C189&amp;ssl=1 300w\" sizes=\"auto, (max-width: 636px) 100vw, 636px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here, I can see that all the fields I wanted are present!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Changing function code to accept incoming NLOG params<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Fairly trivial &#8211; I altered the contents of the function to be as per below. In this code, I simply read the 4 items that my NLOG config is set to provide.   I also changed the method name to something a little nicer than <code>Run()<\/code> as it is more descriptive. However this doesn&#8217;t actually control the endpoint name. To explicitly set the endpoint name I also changed the <code>Route<\/code> from null to &#8220;Log&#8221;. If I wanted to hit \/api\/blah instead of api\/log I would simply do so by changing the route name.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">  public static class Log\n    {\n        [FunctionName(\"Log\")]\n        public static async Task&lt;IActionResult&gt; <strong>AcceptLogRequest<\/strong>(\n            [HttpTrigger(AuthorizationLevel.Anonymous, \"get\", \"post\", <strong>Route = \"Log<\/strong>\")] HttpRequest req,\n            ILogger log)\n        {\n            log.LogInformation(\"HTTP trigger fired for log entry.\");\n            \n            <strong>string timestamp = req.Form[\"timestamp\"]; \n            string loggerName = req.Form[\"loggerName\"]; \n            string loggerLevel = req.Form[\"loggerLevel\"]; \n            string message = req.Form[\"message\"]; \n           \n            var res = $\"{timestamp}   | {loggerName} | {loggerLevel.ToUpper()} | {message}\";\n            log.LogInformation(res);\n\n            \/\/TODO: Persist the data\n\n            return (ActionResult)new OkObjectResult(res);\n<\/strong>\n        }\n    } <\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, if I debug and cause NLOG to log an error, I can see the terminal window and debugger capturing the same information that gets placed in my event log.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Deploying to Azure<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">I will skip the step of connecting to Azure, which is as simple as just pressing &#8220;Sign in&#8221; and following the instructions. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To deploy from VS Code, simply select &#8220;Deploy to Function App&#8221; and then provide a new name of a function to deploy to. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1221\" height=\"93\" data-attachment-id=\"138\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/image-10-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-10.png?fit=1221%2C93&amp;ssl=1\" data-orig-size=\"1221,93\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-10\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-10.png?fit=700%2C53&amp;ssl=1\" src=\"https:\/\/i2.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-10.png?fit=700%2C53\" alt=\"\" class=\"wp-image-138\" srcset=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-10.png?w=1221&amp;ssl=1 1221w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-10.png?resize=300%2C23&amp;ssl=1 300w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-10.png?resize=768%2C58&amp;ssl=1 768w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-10.png?resize=700%2C53&amp;ssl=1 700w, https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-10.png?resize=1200%2C91&amp;ssl=1 1200w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">It takes a while to set up a new function app, but when its done, simply click &#8220;Deploy to function app&#8221;. Thew API will now be accessible via the web (using the azurewebsites url) and Azure dashboard.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"241\" height=\"67\" data-attachment-id=\"139\" data-permalink=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/image-11-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-11.png?fit=241%2C67&amp;ssl=1\" data-orig-size=\"241,67\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-11\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-11.png?fit=241%2C67&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-11.png?resize=241%2C67\" alt=\"\" class=\"wp-image-139\"\/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Wrap up, until next time&#8230;<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So far I have a new Azure Function, which is being contacted by the NLOG Web Service target. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next time I will attempt to persist the incoming logs, using Cosmos DB<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Part of a journey I was on today to learn about Azure Functions and Cosmos DB. The final code for the Azure Functions element can be found on https:\/\/github.com\/Wabbbit\/AzLog Part one: Setup, Creating my first function, forwarding NLOG events and deploying to Azure within VS Code. Part two: persisting the incoming data using Cosmos DB. &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[19,6],"tags":[20,21,22],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-azure","category-development","tag-azure","tag-azure-functions","tag-nlog"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Remote NLOG logging with Azure Functions (Part one). - yer.ac | Adventures of a developer, and other things.<\/title>\n<meta name=\"description\" content=\"Using Azure Functions to remotely log NLOG log entries using NLOG Web Service target. Includes getting started with Azure Functions within VS Code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Remote NLOG logging with Azure Functions (Part one). - yer.ac | Adventures of a developer, and other things.\" \/>\n<meta property=\"og:description\" content=\"Using Azure Functions to remotely log NLOG log entries using NLOG Web Service target. Includes getting started with Azure Functions within VS Code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/\" \/>\n<meta property=\"og:site_name\" content=\"yer.ac | Adventures of a developer, and other things.\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-29T19:21:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-29T19:52:13+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png\" \/>\n<meta name=\"author\" content=\"yer.ac\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"yer.ac\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/\"},\"author\":{\"name\":\"yer.ac\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"headline\":\"Remote NLOG logging with Azure Functions (Part one).\",\"datePublished\":\"2019-05-29T19:21:07+00:00\",\"dateModified\":\"2019-05-29T19:52:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/\"},\"wordCount\":1030,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"image\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/image-4.png\",\"keywords\":[\"Azure\",\"Azure Functions\",\"NLOG\"],\"articleSection\":[\"Azure\",\"Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/\",\"url\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/\",\"name\":\"Remote NLOG logging with Azure Functions (Part one). - yer.ac | Adventures of a developer, and other things.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/image-4.png\",\"datePublished\":\"2019-05-29T19:21:07+00:00\",\"dateModified\":\"2019-05-29T19:52:13+00:00\",\"description\":\"Using Azure Functions to remotely log NLOG log entries using NLOG Web Service target. Includes getting started with Azure Functions within VS Code.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/image-4.png?fit=353%2C331&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/yer.ac\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/05\\\/image-4.png?fit=353%2C331&ssl=1\",\"width\":353,\"height\":331},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/2019\\\/05\\\/29\\\/remote-nlog-logging-with-azure-functions-part-one\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/yer.ac\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Remote NLOG logging with Azure Functions (Part one).\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/yer.ac\\\/blog\\\/\",\"name\":\"yer.ac | Adventures of a developer, and other things.\",\"description\":\"Blog to keep track of things I am upto\",\"publisher\":{\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/yer.ac\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/yer.ac\\\/blog\\\/#\\\/schema\\\/person\\\/4638b9d868c7d3747bd3bb01fbc8153d\",\"name\":\"yer.ac\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\",\"caption\":\"yer.ac\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Remote NLOG logging with Azure Functions (Part one). - yer.ac | Adventures of a developer, and other things.","description":"Using Azure Functions to remotely log NLOG log entries using NLOG Web Service target. Includes getting started with Azure Functions within VS Code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/","og_locale":"en_US","og_type":"article","og_title":"Remote NLOG logging with Azure Functions (Part one). - yer.ac | Adventures of a developer, and other things.","og_description":"Using Azure Functions to remotely log NLOG log entries using NLOG Web Service target. Includes getting started with Azure Functions within VS Code.","og_url":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/","og_site_name":"yer.ac | Adventures of a developer, and other things.","article_published_time":"2019-05-29T19:21:07+00:00","article_modified_time":"2019-05-29T19:52:13+00:00","og_image":[{"url":"http:\/\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png","type":"","width":"","height":""}],"author":"yer.ac","twitter_card":"summary_large_image","twitter_misc":{"Written by":"yer.ac","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/#article","isPartOf":{"@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/"},"author":{"name":"yer.ac","@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"headline":"Remote NLOG logging with Azure Functions (Part one).","datePublished":"2019-05-29T19:21:07+00:00","dateModified":"2019-05-29T19:52:13+00:00","mainEntityOfPage":{"@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/"},"wordCount":1030,"commentCount":0,"publisher":{"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"image":{"@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/#primaryimage"},"thumbnailUrl":"http:\/\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png","keywords":["Azure","Azure Functions","NLOG"],"articleSection":["Azure","Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/","url":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/","name":"Remote NLOG logging with Azure Functions (Part one). - yer.ac | Adventures of a developer, and other things.","isPartOf":{"@id":"https:\/\/yer.ac\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/#primaryimage"},"image":{"@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/#primaryimage"},"thumbnailUrl":"http:\/\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png","datePublished":"2019-05-29T19:21:07+00:00","dateModified":"2019-05-29T19:52:13+00:00","description":"Using Azure Functions to remotely log NLOG log entries using NLOG Web Service target. Includes getting started with Azure Functions within VS Code.","breadcrumb":{"@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/#primaryimage","url":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png?fit=353%2C331&ssl=1","contentUrl":"https:\/\/i0.wp.com\/yer.ac\/blog\/wp-content\/uploads\/2019\/05\/image-4.png?fit=353%2C331&ssl=1","width":353,"height":331},{"@type":"BreadcrumbList","@id":"https:\/\/yer.ac\/blog\/2019\/05\/29\/remote-nlog-logging-with-azure-functions-part-one\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/yer.ac\/blog\/"},{"@type":"ListItem","position":2,"name":"Remote NLOG logging with Azure Functions (Part one)."}]},{"@type":"WebSite","@id":"https:\/\/yer.ac\/blog\/#website","url":"https:\/\/yer.ac\/blog\/","name":"yer.ac | Adventures of a developer, and other things.","description":"Blog to keep track of things I am upto","publisher":{"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/yer.ac\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/yer.ac\/blog\/#\/schema\/person\/4638b9d868c7d3747bd3bb01fbc8153d","name":"yer.ac","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg","caption":"yer.ac"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/67ed010c9cc7986d40647e061c6dcdb06d818776591c7e954055adb629621113?s=96&d=retro&r=pg"}}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paP5IW-1O","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":35,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":179,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions\/179"}],"wp:attachment":[{"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yer.ac\/blog\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}