<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Suyash Shukla on Medium]]></title>
        <description><![CDATA[Stories by Suyash Shukla on Medium]]></description>
        <link>https://medium.com/@suyashshukla1997?source=rss-b7c675922339------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*X1AkPRt2a6qQNDDtxPha2w.png</url>
            <title>Stories by Suyash Shukla on Medium</title>
            <link>https://medium.com/@suyashshukla1997?source=rss-b7c675922339------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 08:25:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@suyashshukla1997/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[CRON Jobs | Hangfire]]></title>
            <link>https://medium.com/@suyashshukla1997/cron-jobs-hangfire-7c2dc1448267?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c2dc1448267</guid>
            <category><![CDATA[hangfire]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 16:54:47 GMT</pubDate>
            <atom:updated>2024-11-02T16:54:47.284Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JYVGOSvrWkRD5eykKXl4EA.png" /></figure><p>Hi Everyone,</p><p>While designing an enterprise grade application, a lot of use cases revolve around having a system which performs scheduled operations at ease with minimal code and configuration. Though timer triggers in app service and functions does serve the use case pretty well but when it comes to visibility and traceability, it falls flat! To come up with an even better alternative here, let us explore the ease with which Hangfire can be configured and used to trigger periodic code executions with minimal efforts.</p><p>The first step towards having a hangfire server is to have its package installed in the project. The same can be picked from here: <a href="https://www.nuget.org/packages/Hangfire/">NuGet Gallery | Hangfire 1.8.15</a></p><p>Once the package is installed, we’ll start writing the code to schedule a recurring job and it goes as under. Hangfire discourages the use of static classes, so we’ll not be going with what the different articles across the web or gen AI prompt suggest, instead we’ll be using the <strong>IRecurringJobManager </strong>instance to schedule our jobs. But before that, we need to initialize hangfire in our application. To do that, invoke the AddHangfire extension on builder.Services and configure the underlying storage where you intend to maintain the Job information. For the purpose of this article, we’ll rely on InMemoryStorage offered by Hangfire as a dedicated nuget package: <a href="https://www.nuget.org/packages/Hangfire.InMemory/">NuGet Gallery | Hangfire.InMemory 1.0.0</a>. The final code will look something like this</p><pre>using System;<br>using Hangfire;<br>using Microsoft.AspNetCore.Builder;<br>using Microsoft.Extensions.DependencyInjection;<br><br>var builder = WebApplication.CreateBuilder(args);<br><br>builder.Services.AddHangfire(config =&gt; config.UseInMemoryStorage());<br>builder.Services.AddHangfireServer();<br>var app = builder.Build();<br>app.Services.GetRequiredService&lt;IRecurringJobManager&gt;().AddOrUpdate(&quot;Print Job&quot;, () =&gt; JobScheduler.Execute(), Cron.Minutely);<br>app.Run();</pre><pre>using System;<br>using System.Threading.Tasks;<br><br>namespace AppFromScratch;<br><br>public class JobScheduler<br>{<br>    public static Task Execute()<br>    {<br>        Console.WriteLine($&quot;{DateTime.UtcNow}: Hello Hangfire!&quot;);<br>        return Task.CompletedTask;<br>    }<br>}</pre><p>Let’s dive deep into all the three statements and understand what they are meant for,</p><ol><li><strong>Add Hangfire</strong></li></ol><pre>builder.Services.AddHangfire(config =&gt; config.UseInMemoryStorage());</pre><p>This statement does the core work of initializing all the required dependencies and runtimes required to run the hangfire worker process. Along with that, we can customize and set the underlying storage for maintaining the triggers, etc. We are using in memory storage for this purpose as already explained above.</p><p><strong>2. Run Hangfire Process</strong></p><pre>builder.Services.AddHangfireServer();</pre><p>Once the preparation is done, it’s the time to run the server and start all the building blocks which support the background execution of hangfire process.</p><p><strong>3. Schedule a Job</strong></p><pre>app.Services.GetRequiredService&lt;IRecurringJobManager&gt;().AddOrUpdate(&quot;Print Job&quot;, () =&gt; JobScheduler.Execute(), Cron.Minutely);</pre><p>Now, since we have configured hangfire and triggered the process execution, we need to setup a job to validate if the triggers are working as expected or not. As evident from the code snippet, this statement will add a Job named <strong>Print Job </strong>which prints <em>Hello Hangfire! </em>every single minute. Let’s run the code and see how it is executing.</p><pre>02/11/2024 4:44:13 pm: Hello Hangfire!<br>02/11/2024 4:45:13 pm: Hello Hangfire!<br>02/11/2024 4:46:13 pm: Hello Hangfire!<br>02/11/2024 4:4y:13 pm: Hello Hangfire!</pre><p>So, as we can observe that the triggers are working as expected without any manual intervention. Hangfire is pretty much extensible with loads of functionalities which can be leveraged for a hell lot of scenarios while building enterprise grade applications.</p><p>It will be a wrap for this article where we’ve learnt the basic of Hangfire and how it operates. Feel free to explore the documentation at length and use it to solve some problem which you feel requires a solution having scheduled execution. Till then, keep learning and exploring. I’ll be back again with something more to ponder and explore!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c2dc1448267" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a web App from scratch]]></title>
            <link>https://medium.com/keka-engineering/building-a-web-app-from-scratch-aa1f67cf8bcd?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa1f67cf8bcd</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 11:24:31 GMT</pubDate>
            <atom:updated>2024-11-02T11:29:50.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wxw83x3EgVsJrl7H-1ANiQ.png" /></figure><p>Hello Everyone,</p><p>Having spent a good amount of time in this vast arena of software engineering, we often reflect back to measure the depth of understanding we have in our domain. I also felt the same need and went ahead to write a .NET app from scratch from a single C# file. So, what you all are waiting for, join me in this exhilarating activity without delaying any further.</p><p>We’ll start with the very basic keeping our first milestone limited to building a console application. To do that, we just need a single file to get started, a CSPROJ file which follows the XML syntax. Let’s quickly create a project directory in whichever working directory you wish to perform this activity</p><pre>md AppFromScratch<br><br>cd AppFromScratch</pre><p>Next step would be to create a new file with a <strong><em>.csproj</em></strong> extension and keep the following content within it which will ensure that the project runs as a console application and under the scope of our desired(target) .NET runtime</p><pre>echo. &gt; AppFromScratch.csproj<br><br>notepad AppFromScratch.csproj</pre><pre>&lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;<br>  &lt;PropertyGroup&gt;<br>    &lt;OutputType&gt;Exe&lt;/OutputType&gt;<br>    &lt;TargetFramework&gt;net8.0&lt;/TargetFramework&gt;<br>  &lt;/PropertyGroup&gt;<br>&lt;/Project&gt;</pre><p>Once the project file is initialized, it can be readily accessed from visual studio to make additional changes. We’ll open the same project in Visual Studio Editor and add a new .cs file to it. (This can be done using command prompt as well). Once the <strong><em>Program.cs</em></strong> file is created, we’ll quickly add a Console Statement and run the code to see how it unfolds</p><pre>using System;<br><br>Console.WriteLine(&quot;Hello World!&quot;);</pre><pre>Hello World!</pre><p>Bingo! The console application is ready and already at par with the templates offered by the dotnet cli. But we’ll not stop here, we’ll travel an extra mile and convert this console app to a fully functional web app.</p><p>The first step to reach there would be the need of a <strong>WebApplication</strong>. We’ll be using the <strong>CreateBuilder </strong>static method to get a builder instance on top of which we’ll start to operate. To gain access to the <strong>WebApplication</strong> class, we need to update our project sdk to <strong>Microsoft.NET.Sdk.Web </strong>from the existing <strong>Microsoft.NET.Sdk. </strong>Once that’s done, our builder can be initialized in this manner</p><pre>using Microsoft.AspNetCore.Builder;<br><br>var builder = WebApplication.CreateBuilder(args);</pre><p>Next steps would be to get an instance of the app by invoking the Build function on builder and subsequently run the complete application by exposing a minimal API endpoint.</p><pre>using Microsoft.AspNetCore.Builder;<br><br>var builder = WebApplication.CreateBuilder(args);<br><br>var app = builder.Build();<br><br>app.MapGet(&quot;/&quot;, () =&gt; &quot;Hello World!&quot;);<br><br>app.Run();</pre><p>Boom! That’s done! You don’t need any additional line of code here to run this web app. Build the project and start the application and see this Hello World string printed on the web UI when accessed through the localhost address mentioned in the application console window.</p><p>Web APIs go a long way from this point covering functionalities ranging from controllers, authentication, authorization, open API specs, etc. amongst many but this code serves as the base for all those incremental changes which will be performed during further development.</p><p>I hope this article is able to provide the much-needed understanding about what goes behind the scenes when we setup an API project template. I’ll be back again with something more to discuss with an aim to make things simpler for the curious readers out there. Till then, keep investing time and efforts to learn and explore your domain and beyond!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa1f67cf8bcd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/keka-engineering/building-a-web-app-from-scratch-aa1f67cf8bcd">Building a web App from scratch</a> was originally published in <a href="https://medium.com/keka-engineering">Keka Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handlebars: The ultimate templating engine!]]></title>
            <link>https://medium.com/keka-engineering/handlebars-the-ultimate-templating-engine-aefe4bfb0cc6?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/aefe4bfb0cc6</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[handlebars]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Fri, 01 Nov 2024 08:38:51 GMT</pubDate>
            <atom:updated>2024-11-01T11:05:58.926Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H2DJCPKoshP5O48I05SR8g.png" /></figure><p>Hi Everyone,</p><p>While designing a system, notifications play a big role to ensure that the customers are notified of the relevant transactions happening within the scope of the application they are using. But designing dynamic templates is one problem which need to solve before building a notification engine.</p><p>In this article, we’ll focus on generating dynamic templates for different notification use cases for a variety of application notifications like Push, Email, etc.</p><p>When we talk about notification content, it is fundamentally a string, formatted or otherwise, where some dynamic fields must be replaced to finalize the refined content before dispatching it to end users.</p><pre>var templateString = Hi {{DisplayName}}, Your KYC for Credit Card is {{Status}}.</pre><p>This message can take multiple forms based on object binding which differs from user to user. Handlebars comes into the picture at this very juncture. String replacement might not be the best way to move forward because of performance constraints. What handlebars does different is a placeholder lookup instead of direct string substitution. This ensures that performance is not compromised in pursuit of a dynamic template generation. Let’s move ahead and explore how we can leverage the power of Handlebars in C# using it’s .NET variant. You can install the nuget package from here: <a href="https://www.nuget.org/packages/Handlebars.Net">NuGet Gallery | Handlebars.Net 2.1.6</a></p><p>The first step towards working with Handlebars is to create an instance. Here’s a catch, you need not to define one since the basic functionalities are offered as a static function itself. So, we’ll compile a dynamic first to make it accessible further operations</p><pre>var template = HandlebarsDotNet.Handlebars.Compile(templateString);</pre><p>Now, the next step would be to bind dynamic objects to generate different variants. Let’s create a class to maintain the possible values for user KYC details which will be further substituted to our template to derive the dynamic content.</p><pre>public class UserKycDetails<br>{<br>    public string DisplayName { get; set; }<br><br>    public string Status { get; set; }<br><br>    public static UserKycDetails Create(string displayName, string status)<br>    {<br>        return new UserKycDetails()<br>        {<br>            DisplayName = displayName,<br>            Status = status<br>        };<br>    }<br>}</pre><p>The class is defined. Let’s go ahead and build a list with some probable values which we would like to replace in the template prepared in the previous step.</p><pre>List&lt;UserKycDetails&gt; userKycDetails = [<br>    UserKycDetails.Create(&quot;Suyash Shukla&quot;, &quot;Approved&quot;),<br>    UserKycDetails.Create(&quot;Gulshan Grover&quot;, &quot;Rejected&quot;),<br>    UserKycDetails.Create(&quot;Ramesh Sippi&quot;, &quot;Pending&quot;)<br>]</pre><p>Now, we’ll be iterating over this list to generate the dynamic template strings using handlebars</p><pre>foreach (var kyc in userKycDetails) {<br>    Console.WriteLine(template.Invoke(kyc));<br>}</pre><p>Once this complete code is executed, the console output will be something like this,</p><pre>Hi Suyash Shukla, Your KYC for Credit Card is Approved.<br>Hi Gulshan Grover, Your KYC for Credit Card is Rejected.<br>Hi Ramesh Sippi, Your KYC for Credit Card is Pending.</pre><p>This is a very basic usage explanation of handlebars. The kind of benefits it provides are way beyond regular placeholder replacement. Let’s see, how we can loop over a list to populate statements through a single template invocation. To do this, we’ll introduce another property called approval logs in the KYC object and change the template string to facilitate printing those logs during invocation. Now, the final code will look similar to the following gist.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd85e2697c076251eaeee9e776d5cfbd/href">https://medium.com/media/cd85e2697c076251eaeee9e776d5cfbd/href</a></iframe><p>As evident from the code, we have used <strong><em>{{#each}}</em></strong><em> </em>helper to iterate over the approval logs list and print the individual element separately. For the sake of simplicity, we kept the type of the element as string, but it is extensible enough to allow any form of custom objects. The output of this code execution will be as under</p><pre>Hi Suyash Shukla, Your KYC for Credit Card is Approved.<br>&gt; Initiated on 1st October<br>&gt; Sent for review on 15th October<br>&gt; Approved on 23rd October<br>Hi Gulshan Grover, Your KYC for Credit Card is Rejected.<br>Hi Ramesh Sippi, Your KYC for Credit Card is Pending.</pre><p>In the code attached above, we are accessing the loop element using <strong>this </strong>keyword. This behavior stays the same for all loop elements, no matter you are iterating over a list of primitives like string or over a list of objects.</p><p>One more exciting helper which handlebar offers is <strong>{{#if}}.</strong> Yes, we can dynamically take the decisions to toggle the visibility of a string segment based on this helper evaluation. Let’s expose another property to our kyc object based on which, a congratulatory message must be printed to the console. The gist with these code changes is as under</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06ff2bb298258611f3fb27a43e945cef/href">https://medium.com/media/06ff2bb298258611f3fb27a43e945cef/href</a></iframe><p>As you can observe, we are only printing one additional sentence when the CanTransact flag is set to true. This is achieved by simply enclosing the conditional statement withing the scope of a <strong>{{#if}}</strong> helper.</p><p>Handlebar helpers are not limited to the pre-defined structs and syntaxes, we can define custom helpers and render it in the way we want. Handlebars are extensively as an email template engine which increases it utility even more. It is a pretty rich library which has a lot to offer for different application needs. Sit back and explore it to as much extent as possible.</p><p>I’ll wrap it here keeping this article open for suggestions or feedback. I’ll be back again with something new to dive deep into. Till then, keep learning and exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aefe4bfb0cc6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/keka-engineering/handlebars-the-ultimate-templating-engine-aefe4bfb0cc6">Handlebars: The ultimate templating engine!</a> was originally published in <a href="https://medium.com/keka-engineering">Keka Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing JSON Data | Azure Blob Storage]]></title>
            <link>https://medium.com/keka-engineering/managing-json-data-azure-blob-storage-ce47ee7b825e?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce47ee7b825e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Wed, 30 Oct 2024 06:47:16 GMT</pubDate>
            <atom:updated>2024-11-01T11:07:07.505Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MBeFrV9-yWkQzHqEzQy03Q.png" /></figure><p>Hi Everyone,</p><p>When it comes to managing JSON data, a lot of methods storm our mind but recently we came across a hack through which we can write data to JSON files and push them to azure blobs with ease.</p><p>We were working on maintaining temporary data which will be later read and pushed to primary storage based on a specific user action. Holding it in SQL will not be a space effective solution considering the capacity constraints we have with managed azure databases.</p><p>Next best solution available to us was Azure Table Storage since the need revolved around managing a read only record with no writes. And NoSQL makes the cut in all such scenarios. This method worked well to some extent until we realized that at the scale at which we operate, the column constraint of 64KB and row constraints of 1MB can be very easily breached. It didn’t take much time before the storage write started to fail due to oversized data. This occurrence brought us back to our drawing boards again and we started brainstorming on an alternative solution. That’s when our EM gave us an idea of storing it as a file and read the file content when needed using the blob reference.</p><p>We again spent some time thinking about this possibility and that’s when I was able to recall that Azure themselves do something similar for storing web application firewall logs in storage accounts. Without wasting any further time, we decided that we’ll be sticking with this method and proceed with the remaining part of the implementation. Not only, we were able to overcome this obstacle by following the aforementioned method but also release the feature in real quick time covering an exhaustive test suite with variety of data involved. Let’s dive deep into how this can be achieved using C#, .NET and Azure Blobs,</p><p>The first step towards pushing JSON data to blob is to have a class, its object and build a JSON string from that object, this can be achieved using the preexistent JSON Serializers in .NET</p><pre>public class Person {<br>  <br>  public string Name { get; set; }<br><br>  public int Age { get; set; }<br><br>  public DateOnly DateOfBirth { get; set; }<br><br>}</pre><pre>var person = new Person() {<br>   Name = &quot;Suyash&quot;,<br>   Age = 27,<br>   DateOfBirth = DateOnly.FromDateTime(new DateTime(1997,3,3))<br>  };<br><br>string jsonString = System.Text.Json.JsonSerializer.Serialize(person);<br><br>Console.WriteLine(jsonString);</pre><pre>{<br>    &quot;Name&quot;: &quot;Suyash&quot;,<br>    &quot;Age&quot;: 27,<br>    &quot;DateOfBirth&quot;: &quot;1997-03-03&quot;<br>}</pre><p>Now, since we have the JSON string ready with us, the next step would be to initialize a blob client and push this content to a blob reference. But for that we need to convert the string to a byte content,</p><pre>var byteContent = System.Text.Encoding.UTF8.GetBytes(jsonString);</pre><p>Now, the data is ready, and upload logic is pending to be written. So, without delaying it any further, let’s jump on to the core part of this code which will establish a connection to storage account and push the JSON data to cloud.</p><pre>// Create a connection to the azure storage account.<br>var blobServiceClient = new BlobServiceClient(&quot;AZURE_STORAGE_ACCOUNT_CONNECTION_STRING&quot;);<br><br>// Retrieve the container client and subsequently create it if it does not exists already.<br>// Containers are like buckets in which we store data.<br>var blobContainerClient = blobServiceClient.GetBlobContainerClient(&quot;json_data&quot;);<br><br>if (!containerClient.Exists())<br>{<br>    containerClient.Create();<br>}<br><br>// Create a blob name, all segments separate by a / becomes a directory inside a container.<br>var blobName = $&quot;{DateTime.UtcNow.Year}/{DateTime.UtcNow.Month}/{DateTime.UtcNow.Day}/{Guid.NewGuid()}.json&quot;;<br><br>// Retrieve a blob client using the blob name and container client.<br>var blobClient = containerClient.GetBlobClient(blobName);<br><br>// Set the blob headers to define the content type of the file to be uploaded<br>var blobHeaders = new BlobHttpHeaders<br>{<br>    ContentType = &quot;application/json&quot;<br>};<br><br>// Trigger the upload function to push the data to blob<br>await blobClient.UploadAsync(new MemoryStream(byteContent), blobHeaders);</pre><p>We were able to generate and store the JSON data to blob, how to read it now? The answer is fairly simple, we’ll read it over a network call as a byte array and covert it to string again. Let’s see how to attempt this operation</p><pre>// Generate a SAS URL to gain acccess to the blob over a URL<br>var blobUrl = blobClient.GenerateSasUri(Azure.Storage.Sas.BlobSasPermissions.Read, DateTimeOffset.Now.AddHours(1)).AbsoluteUri;<br><br>// Retrieve the blob content as byte array<br>var blobContent = await new HttpClient().GetByteArrayAsync(blobUrl);<br><br>// Convert the byte array to string<br>var jsonString = System.Text.Encoding.UTF8.GetString(blobContent);<br><br>// Deserialize the json string as the required object<br>var personObject = System.Text.Json.JsonSerializer.Deserialize&lt;Person&gt;(jsonString);</pre><p>So, without worrying much about the space limitation in SQL or column constraints in Table Storage, we can store JSON data in blob with minimal code changes at an expense of some additional network latency.</p><p>Storing and managing data for different use cases is in itself a big domain of system design. It is definitely not like one size fits all but solution for one problem can definitely be leveraged for different needs and requirements. Keeping that into mind, I thought of sharing this experience to my readers.</p><p>I’ll be back again soon with something new to learn and explore in this vast universe of software development and cloud. Till then, keep learning and exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce47ee7b825e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/keka-engineering/managing-json-data-azure-blob-storage-ce47ee7b825e">Managing JSON Data | Azure Blob Storage</a> was originally published in <a href="https://medium.com/keka-engineering">Keka Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure Redis CLI]]></title>
            <link>https://medium.com/keka-engineering/azure-redis-cli-ae7a8fd5a56a?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae7a8fd5a56a</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Mon, 28 Oct 2024 05:38:21 GMT</pubDate>
            <atom:updated>2024-11-01T11:07:41.043Z</atom:updated>
            <content:encoded><![CDATA[<h3>Azure Redis CLI Cheat Sheet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0SuhpZo-w1Z8-xn8QpPmQ.png" /></figure><p>Hi Everyone,</p><p>We all are very much aware of the use cases for Azure Redis Cache and leverage it quite extensively for our application requirements. But there’s more to it than just interacting with the Redis Client SDK from our code. We can get a sneak peek into our data using the Redis Console which is readily accessible from Azure Portal.</p><p>Let’s start from the very basic commands to validate if the Redis CLI is initialized successfully or not. To do that, we’ll use the following command</p><pre>&gt; PING</pre><p>To this, the CLI responds with the following output to confirm that the Redis CLI is up and running without any glitches and the connection is established.</p><pre>&gt; PING<br>PONG</pre><p>Since the connection is established now, we’ll go ahead and see what all keys are present in Redis to plan our subsequent queries on top of that response.</p><p>To do that, we’ll use the following command which will give us enough flexibility to define the following parameters to customize the search,</p><ol><li>Starting index for search</li><li>Number of entries to return: An analogue to TOP command in SQL</li><li>Matching substring: Similar to LIKE operator in SQL</li></ol><pre>&gt; SCAN &lt;STARTING_INDEX&gt; COUNT &lt;RETURN_COUNT&gt; MATCH &lt;SUBSTRING&gt;</pre><p>Structuring our data retrieval query to fit in the prescribed format</p><pre>&gt; SCAN 0 COUNT 1000 MATCH *</pre><p>Upon execution, this command will eventually return all keys present in the cache starting 0th index limited to 1000 records.</p><p>Once we have the keys, let’s see how we can read the data present within it, to achieve it, we have read commands for different value types. For the sake of simplicity, we’ll keep it limited to strings and objects. The same goes as under,</p><pre>#String<br>GET &lt;KEY_NAME&gt;<br><br>#Hash (Objects)<br>HGETALL &lt;KEY_NAME&gt;</pre><p>The insertion method is also different for both the types, and it can be done in the following manner</p><pre>#String<br>SET &lt;KEY_NAME&gt; &lt;VALUE&gt;<br>E.g. SET name &#39;suyash&#39;<br><br>#Hash (Objects)<br>HSET &lt;KEY_NAME_ONE&gt; &lt;VALUE_ONE&gt; ..... &lt;KEY_NAME_N&gt; &lt;VALUE_N&gt;<br>E.g. HSET person name &#39;suyash&#39; age 27 city &#39;hyderabad&#39;</pre><p>Now, we’ll just read the insert values to validate if the data is pushed correct to Redis</p><pre>&gt; GET name<br>&quot;suyash&quot;<br>&gt; HGETALL person<br>1) &quot;name&quot;<br>2) &quot;suyash&quot;<br>3) &quot;age&quot;<br>4) &quot;27&quot;<br>5) &quot;city&quot;<br>6) &quot;hyderabad&quot;</pre><p>We can go a step further while interacting with Redis Hash by retrieving just the information we need within an object. This can be achieved by using the HGET command. Check the example below to understand it better,</p><pre>&gt;HGET &lt;KEY_NAME&gt; &lt;HASH_KEY_NAME&gt;<br>E.g. HGET person name<br>&quot;suyash&quot;</pre><p>But we are just able to read a single key value within a hash(object). What to do when we wish to perform a multiple key retrieval within a hash? That’s when HMGET comes into the picture, by just specifying space separate key names, it helps us retrieve the underlying information stored in Redis.</p><pre>&gt;HMGET &lt;KEY_NAME&gt; &lt;HASH_KEY_NAME_ONE&gt; ..... &lt;HASH_KEY_NAME_N&gt;<br>E.g. HMGET person name age city<br>1) &quot;suyash&quot;<br>2) &quot;27&quot;<br>3) &quot;hyderabad&quot;</pre><p>In a nutshell, HGET, HMGET and HGETALL are the different variants of data retrieval commands which can be utilised based on the underlying use case.</p><p>Redis is not just limited to Strings and Hashes. It is a very powerful tool which can be used for a plethora of different scenarios. Taking the learnings from this article as a head start, we can form our own caching mechanisms and architecture around Redis for a low latency experience to end user.</p><p>I hope this article was able to assist the readers in getting accustomed to Redis CLI. I’ll be back with more such interesting reads in the coming days circling around some other aspect of software development and cloud. Till then, keep learning and exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae7a8fd5a56a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/keka-engineering/azure-redis-cli-ae7a8fd5a56a">Azure Redis CLI</a> was originally published in <a href="https://medium.com/keka-engineering">Keka Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pull Request Status Check]]></title>
            <link>https://medium.com/keka-engineering/pull-request-status-check-60f0dfddea70?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/60f0dfddea70</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 10:55:40 GMT</pubDate>
            <atom:updated>2024-11-01T11:07:55.430Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6lQYAAx-hq6mcPF2uhGUuQ.png" /></figure><p>Hi Everyone,</p><p>In our bid to imbibe the processes and workflows incorporated in the different version control systems leveraged by the organizations, we might have occasionally come across custom pull request merge checks beyond the conventional rule-based policies. Though, VCS tools provide us enough pre-defined checks related to builds, votes, conventions, etc. but they don’t suffice the needs of organizations who follow their own policies for development and the existing rules can’t be stretched to a great extent in order to facilitate that. To cover this very aspect of VCS ops, I’ll be demonstrating the available webhooks in azure DevOps along with the post back mechanism using which the application admins can configure custom pull request checks.</p><p>The very first step would be to understand the complete end to end mechanism of what goes behind the scenes from the point of webhook trigger to the post back to the azure DevOps endpoints.</p><ul><li>Azure DevOps sends an event message to the rest endpoint configured under the service hooks.</li><li>The endpoint consumes the data from DevOps server and processes it to evaluate the applicability of a rule.</li><li>The evaluated result is mapped to the expected API payload for azure DevOps PR Status endpoint and an HTTP request is triggered to it. In this API payload, we send the name and genre which is consumed by the PR endpoint to identify the applicability based on the configured policy.</li><li>The branch policy is configured to listen to the PR Status with a specific name and genre based on which it identifies if the incoming request need to be considered as an applicable policy or not.</li></ul><p>So overall, the complete flow includes a webhook notification to our server from Azure DevOps followed by a POST request back to the Azure DevOps PR Status Endpoint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*v1BBTmZs807OJZ6hQWXZQQ.png" /></figure><p>Now, since we are aware of the underlying flow, let’s quickly move towards the configurations involved to achieve the desired result.</p><ul><li>You must have an Azure DevOps organization with privileges to manage service hooks.</li><li>You must have an Azure Subscription to provision Azure Function or any other cloud resource across providers where an endpoint can be hosted to consume webhook notifications from Azure DevOps.</li></ul><h3>Step 1:</h3><ul><li>Create an Azure Function Application with HTTP Trigger and deploy it to cloud. For more info on how to do it, do give a read to this article: <a href="https://medium.com/keka-engineering/world-of-faas-8af06afdc96f">World of FaaS!. Hello Everyone, | by Suyash Shukla | Keka Engineering | Medium</a>.</li><li>I’ve deployed the default function code with an updated route name to my function app on Azure.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0zmKVEQ83g6wFjIbMBDxMQ.png" /></figure><ul><li>Once the Azure Function is live, we’ll configure the endpoint in our Azure DevOps project’s service hooks. To do that, locate the function on azure portal and hit Get Function URL to access the endpoint URL for the function.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yizi5aMMNtxyxfXxdML6JA.png" /></figure><ul><li>Now we’ll be configuring this URL in our Azure DevOps project. To access that, head over to Project Settings present in the navigation blade of DevOps portal and find Service Hooks in the left pane.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_G26_GNBcaEK6iP9Ksb4rA.png" /></figure><ul><li>We’ll be adding a new subscription to listen to the available events through Web Hook Service. We’ll start with the basic event of Pull Request Created and configure it to post the data to our function URL. Readers are free to explore other events for their desired use cases.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*iXZJ7j4a0G8gXew_ifJC3Q.png" /></figure><ul><li>Test the webhook and check if the endpoint is able to receive the notification. Since, we haven’t done any code changes yet, it will return 200 OK Status directly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*Q6cNopiMRazfEkAGsKqM2w.png" /></figure><h3>Step 2:</h3><ul><li>Now, we have the web hooks configured and thus code changes can be attempted to post back the custom status to PR Endpoints available in Azure DevOps.</li><li>We’ll define a REST communication flow for this API keeping only the minimal fields to make it work.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3e12de4df1d6a37ff0e9aed06d70f70/href">https://medium.com/media/f3e12de4df1d6a37ff0e9aed06d70f70/href</a></iframe><ul><li>Once the request payload is ready, we need to post it to the PR Status endpoint for the pull request against which the event would’ve been raised. The event details are already sent by Azure DevOps server as part of the webhook notification, and it is structured in the following manner.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f84c992c5060ef8e555aaec67bdd991e/href">https://medium.com/media/f84c992c5060ef8e555aaec67bdd991e/href</a></iframe><ul><li>As evident from the object breakdown, we just need to interact with the Resource property of the webhook response to write custom validation. So, what are we waiting for, let’s head over to some coding.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afabc0e8ab1dd95be67d69f0b768fbc6/href">https://medium.com/media/afabc0e8ab1dd95be67d69f0b768fbc6/href</a></iframe><ul><li>So, here we are sending back a dynamic status based on the length of pull request title to identify if the PR is valid or not.</li><li>Now comes the HTTP interaction with the azure DevOps endpoints. Since it is a protected resource, we need to generate a PAT Token for authentication. The process of generating PAT in Azure DevOps is already explained in this article: <a href="https://medium.com/keka-engineering/deciphering-devops-build-agents-and-pipelines-25cf9f806790">Deciphering DevOps | Build Agents and Pipelines | by Suyash Shukla | Keka Engineering | Medium</a></li><li>Once we have the PAT Token available with us, we just need to make a POST Call to the PR status endpoint and with this, we can draw this configuration change to a close.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8c979ccecb5a076b72e201a5cfff254/href">https://medium.com/media/a8c979ccecb5a076b72e201a5cfff254/href</a></iframe><ul><li>We’ll deploy the code after making this change and move to the final point of this exercise where the branch policies will be configured to listen to the name and genre of this coverage check.</li></ul><h3>Step 3</h3><ul><li>Now, we have established the end-to-end communication from azure DevOps to our function app and vice versa. The function will continuously post the coverage status as and when it will receive the webhook notification but how to link the coverage check with the pull request policies?</li><li>To do that, we’ll head over to the Repositories section under Projection Settings and navigate to the branch policies and start setting up one for our use case.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tCDxIP6k9rWeUf2g_pIoZg.png" /><figcaption>Status Check Configuration</figcaption></figure><ul><li>By adding a status check including the name and genre we mentioned in our response payload, we’ll be able to link the status post back to our branch policies.</li><li>Now, we’ll quickly create a new pull request to see our changes in action.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IWCxGaTriRy9PXddXXeLQw.png" /><figcaption>PR Title less than 36 characters</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aWAc0nCOl6Xi-ZYNSEgFHA.png" /><figcaption>PR Title more than 36 characters</figcaption></figure><p>With this, we have come to an end of this comprehensive article on status checks of pull requests. Just to mention that there are a lot of web hook events available in Azure DevOps which can be leveraged to increase developer and team productivity. Do give them a read to see if you all can identify any other daily development/DevOps use case which can be automated in a streamlined manner by using the flow which we have discussed here. I’ll be back again soon with something new to share across the techno functional domain of software development and cloud computing. Till then, keep learning and exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60f0dfddea70" width="1" height="1" alt=""><hr><p><a href="https://medium.com/keka-engineering/pull-request-status-check-60f0dfddea70">Pull Request Status Check</a> was originally published in <a href="https://medium.com/keka-engineering">Keka Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Web Job and Web App to Azure]]></title>
            <link>https://medium.com/keka-engineering/deploy-web-job-and-web-app-to-azure-8099f6c88fe?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/8099f6c88fe</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 13:55:34 GMT</pubDate>
            <atom:updated>2024-11-01T11:08:40.623Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kfm1EJo_XMPKKpXcnaWiUw.png" /></figure><p>Hi Everyone,</p><p>Since we are aware of setting up a web job using Azure SDK, the next step would be to deploy it to a cloud resource. Readers who are yeto to get accustomed to Azure Web Jobs can refer this article for a quick start: <a href="https://medium.com/keka-engineering/azure-timer-jobs-1ab01f88f5df">Azure Timer Jobs</a></p><p>In this article, we’ll be deploying Triggo Web Job along with a Web Application to the same Azure App Service resource. But before we go ahead with the deployment, we must know how the App Service Deployment Model. All application hosts reside within the <strong>site </strong>directory in App Services and from there on the bifurcation of WebJobs and WebApp happens as under:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*YzpLVasqaFyGT-YF5LGhNQ.png" /><figcaption>App Service File Structure</figcaption></figure><p>Considering this very path structure, we’ll be writing our build definitions which would push our web app and web job to an app service cloud resource. But before we do that, we need to update our solution to include a sample web app as well along with the existing Web Job. Once done, our solution will look something similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*5A38YMOQ2kfWUEggubJ2-w.png" /><figcaption>Triggo App File Structure</figcaption></figure><p>Now we’ll push this code to our version control system and link it with some automated CI/CD Tasks. I’ll be doing it using Azure DevOps. We’ll make use of the existing ASP NET Core Build Templates with an additional Task to publish the Web Job content to the desired job directory which is understandable by app service runtime.</p><p><strong><em>Note</em></strong><em>: We need to ensure that the content is not zipped since we are going forward to deploy a composite app with a single build artifact and cloud resource.</em></p><pre># For Web App<br>--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)<br><br># For Web Job<br>--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)/app_data/jobs/continuous/triggo.job</pre><p>Once this is done, we’ll quickly build our artifact and move ahead with app service deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*irZx_QVkubMbnqb0ql4yYg.png" /><figcaption>Artifact Structure</figcaption></figure><p>Now, let’s quickly define our CD Tasks for deploying the code to Azure App Service and see our web and worker running simultaneously in a single unit of cloud resource.</p><p>I already have an app service provisioned in my azure subscription hence I’ll be making use of it to deploy my code. Please ensure if you are performing variable substitution, use the wildcard for locating all json files in the build artifact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*o9k084qva-KUsbvhXYSZuA.png" /><figcaption>JSON Variable Substituion</figcaption></figure><p>Along with this, we need to configure the deployment package to be picked from a directory rather than a zip file through a wildcard since all our output files are lying flat in the build artifact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*iifC1mz2NZtUjDhu9JtxEw.png" /><figcaption>Deployment Package Configuration</figcaption></figure><p>And that’s it! We are good to go with the deployment of this composite chunk of code which will power a web app and web job simultaneously through Azure App Service. To verify if everything is running as expected, we can access the web app over FQDN and check for the logs of Job Execution in our linked storage account as we have configured the same in the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*llYlMo-eLF1TH3sOxk38Ew.png" /></figure><p>This concludes our tutorial on running web and worker over a single cloud resource using Azure App Service and Web Jobs. It can be leveraged to serve even more technical requirements with ease. I’ll be back again with more immersive content on software development and cloud. Till then keep learning and exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8099f6c88fe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/keka-engineering/deploy-web-job-and-web-app-to-azure-8099f6c88fe">Deploy Web Job and Web App to Azure</a> was originally published in <a href="https://medium.com/keka-engineering">Keka Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure Timer Jobs]]></title>
            <link>https://medium.com/keka-engineering/azure-timer-jobs-1ab01f88f5df?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ab01f88f5df</guid>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Thu, 23 Feb 2023 05:21:02 GMT</pubDate>
            <atom:updated>2024-11-01T11:09:02.208Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IMNb19sN-PEAATVv3oQXDQ.png" /></figure><p>Hello Everyone,</p><p>Out of all the use cases which current age application developers address through scalable solutions, the ability to perform scheduled operations holds a pretty prominent place amongst them! Azure Web Jobs gives us this very ability which can be utilized for a variety of application requirements. This tutorial primarily focuses on guiding the readers to setup their own Timed Job using Azure Web Jobs SDK.</p><p>Let me specifically define the functional aspects of the application we are planning to build,</p><p><strong>Triggo </strong>is a console application which runs every single minute and push a record with the execution details to a Table Storage data store.</p><p>Keeping this into context, let’s start bootstrapping the application with the following Nuget Packages:</p><ul><li><strong>Azure.Data.Tables</strong>: For the purpose of capturing and reading records from Table Storage</li><li><strong>Microsoft.Azure.WebJobs.Extensions</strong>: For the purpose of intializing WebJobs and defining Triggers</li><li><strong>Microsoft.Extensions.Hosting</strong>: For bootstrapping the application using HostBuilder</li></ul><p>Once the required Nuget Packages are added, we’ll create a function and add initialization logic to it:</p><pre>// Meant to intialize the application host and ensure that jobs are configured<br>void InitializeWebJob() { }</pre><h4>Initialize Web Job</h4><p>We’ll be invoking the <em>ConfigureWebJobs </em>Function on the Host Builder to configure our Timer Job</p><pre>InitializeWebJob();<br><br>// Meant to intialize the application host and ensure that jobs are configured<br>void InitializeWebJob()<br>{<br>    var builder = new HostBuilder();<br>    builder.ConfigureWebJobs((jobBuilder) =&gt; jobBuilder.AddTimers());<br>    var host = builder.Build();<br>    host.Run();<br>}</pre><p>This code is enough for you to get started with Azure Time Jobs and upon startup, the relevant code will start executing as per the defined trigger.</p><h4>Timer Trigger Listener</h4><p>This listener acts as the consumer for the defined Trigger. We’ll add a Timer Trigger to a new class named <em>JobHandler </em>which will execute every minute and push a log to console,</p><pre> public class JobHandler<br> {<br>     // This is a fucntion where we&#39;ll be defining the Timer Trigger<br>     public void TimerTriggerListener([TimerTrigger(&quot;*/1 * * * *&quot;, RunOnStartup = false)] TimerInfo timerInfo)<br>     {<br>         Console.WriteLine($&quot;Job Executed Successfully at {DateTime.Now:F}!&quot;);<br>     }<br> }</pre><p>Once this is done, we can go ahead and test out application if the triggers are working as expected or not but before we start, we need to perform another configuration for the purpose of Azure Web Job Execution. The trigger related information needs to be preserved in a storage account for which we need to define it in our configuration file for the Web Jobs SDK to consume.</p><pre>{<br>  &quot;AzureWebJobsStorage&quot;: &quot;STORAGE_ACCOUNT_CONNECTION_STRING&quot;<br>}</pre><p>And that’s it, we can go ahead and start our application to experience the power of Azure Web Jobs. You can find the logs in console which confirms that our jobs are running fine.</p><pre>Job Executed Successfully at 23 February 2023 10:20:01!<br>Job Executed Successfully at 23 February 2023 10:21:00!<br>Job Executed Successfully at 23 February 2023 10:22:00!<br>Job Executed Successfully at 23 February 2023 10:23:00!<br>Job Executed Successfully at 23 February 2023 10:24:00!<br>Job Executed Successfully at 23 February 2023 10:25:00!<br>Job Executed Successfully at 23 February 2023 10:26:00!<br>Job Executed Successfully at 23 February 2023 10:27:00!<br>Job Executed Successfully at 23 February 2023 10:28:00!<br>Job Executed Successfully at 23 February 2023 10:29:00!<br>Job Executed Successfully at 23 February 2023 10:30:00!<br>Job Executed Successfully at 23 February 2023 10:31:00!<br>Job Executed Successfully at 23 February 2023 10:32:00!<br>Job Executed Successfully at 23 February 2023 10:33:00!<br>Job Executed Successfully at 23 February 2023 10:34:00!</pre><p>This is just one part of it, the other requirements of Triggo would be fulfilled when we start dumping these console logs to a Table Storage. For that to happen, we need to intialize a TableEntity which carries an additional property Message in addition to the Azure Defined Attributes.</p><pre>public class LogEntity : ITableEntity<br>    {<br>        public string Message { get; set; }<br><br>        public string PartitionKey { get; set; }<br><br>        public string RowKey { get; set; }<br><br>        public DateTimeOffset? Timestamp { get; set; }<br><br>        public ETag ETag { get; set; }<br><br>        public static LogEntity Build(string message)<br>        {<br>            return new LogEntity()<br>            {<br>                Message = message,<br>                PartitionKey = &quot;LogEntity&quot;,<br>                RowKey = Guid.NewGuid().ToString(),<br>                Timestamp = DateTimeOffset.Now,<br>                ETag = ETag.All<br>            };<br>        }<br>    }</pre><p>Once this entity is created, we need to define a <em>TableStorageClient </em>which pushes the built data to Table Storage.</p><pre>public class JobHandler<br>    {<br>        public TableClient TableClient { get; set; }<br><br>        public JobHandler(IConfiguration configuration)<br>        {<br>            var tableServiceClient = new TableServiceClient(configuration[&quot;TableStorageConnectionString&quot;]);<br>            this.TableClient = tableServiceClient.GetTableClient(typeof(LogEntity).Name);<br>            this.TableClient.CreateIfNotExists();<br>        }<br><br>        // This is a fucntion where we&#39;ll be defining the Timer Trigger<br>        public void TimerTriggerListener([TimerTrigger(&quot;*/1 * * * *&quot;, RunOnStartup = false)] TimerInfo timerInfo)<br>        {<br>            string message = $&quot;Job Executed Successfully at {DateTime.Now:F}!&quot;;<br>            this.TableClient.AddEntity(LogEntity.Build(message));<br>            Console.WriteLine(message);<br>        }<br>    }</pre><p>Once these changes are added, let’s restart our application to push the logs to Table Storage on every job trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1bXrhN_wRVvaP8qIiyScQ.png" /><figcaption>Azure Storage Explorer</figcaption></figure><p>With this, we are done with a basic Timed Web Job Application which covers the fundamental configuration of setting it up along with performing a periodic operation on every trigger.</p><p>Azure Web Jobs can be utilized to an even further extent based on the application requirements. I’ll leave it on the readers to explore and build scalable solutions with this powerful SDK. The next article will focus on deploying the built Web Job to Azure App Service using CI/CD Tasks. Till then, keep learning and exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ab01f88f5df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/keka-engineering/azure-timer-jobs-1ab01f88f5df">Azure Timer Jobs</a> was originally published in <a href="https://medium.com/keka-engineering">Keka Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dapper Extensions]]></title>
            <link>https://medium.com/keka-engineering/dapper-extensions-f97f29a5e23b?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/f97f29a5e23b</guid>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[orm]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Tue, 21 Feb 2023 12:28:19 GMT</pubDate>
            <atom:updated>2024-11-01T11:10:09.432Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AjDeTf-jQvqb5u9iLszWHg.png" /></figure><p>Hi Everyone,</p><p>It’s been a while since I last published an article and what’s better to start than diving into one of the ORMs which are extensively used in the Dot-Net community.</p><p>To all those who are wondering, what it’s all about, let me reveal it upfront for the readers to ponder and imbibe!</p><p>Dapper provides some augmented extension methods for our basic querying need but the underlying functions to perform parameterized operations is still something which can be refined to a great extent. But how do we do it? We’ll be writing extensions on top of the <em>IDbConnection</em> interface to enhance the already powerful date retrieval functions of Dapper.</p><p>To start with, let’s setup a console application which connect to a SQL Server Database. For this to happen, the following packages are required to be added to our project:</p><ul><li><strong>Dapper: </strong>For the purpose of accessing Dapper Extensions in our code</li><li><strong>System.Data.SqlClient: </strong>For the purpose of connection to SQL Server DB</li></ul><p>Once the required packages are added, we can go ahead and initialize the DB Connection to our SQL Server as under:</p><pre>// Initializing the DB Connection to SQL Server<br>var connectionString = &quot;Server=tcp:sql-azure-app-dev-cin.database.windows.net,1433;Initial Catalog=sqldb;Persist Security Info=False;User ID=sqldb-azure;Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;&quot;;<br>IDbConnection dbconnection = new SqlConnection(connectionString);</pre><p>Once done, we can leverage the Dapper ORM by invoking the querying methods on the <em>dbConnection </em>instance created earlier.</p><p>Let’s start performing some querying operation to understand it better!</p><p>I have a prewritten script which initializes a generic employee entity in fresh database with some dummy records. You can find the script here: <a href="https://gist.github.com/suyashshukla/21168982db9cf52ee66d1b7bb46cbf0e">Employee.sql (github.com)</a></p><p>Once your sample DB and Entities are initialized, we’ll create a Model which can be used by the ORM to Map the Relational Data to an object in C#.</p><pre>    public class Employee<br>    {<br>        public string FirstName { get; set; }<br><br>        public string LastName { get; set; }<br><br>        public string Title { get; set; }   <br><br>        public int Age { get; set; }<br><br>        public int Salary { get; set; }<br>    }</pre><p>With this model, we have covered all the necessary pre-requisites for the purpose of this tutorial. Now, let’s jump onto the experimentation ground.</p><ul><li>Fetch All Employee Records</li></ul><pre><br>// Fetch All Employee Records<br>var employees = dbconnection.Query&lt;Employee&gt;(&quot;SELECT * FROM Employee&quot;);</pre><p>Fetch operations are comparatively easy when data is not required to be filtered on a specific property. Let’s tweak the data requirement a bit to understand how Dapper can deal with it,</p><ul><li>Fetch All Employee Records whose first name is <strong><em>John</em></strong></li></ul><pre>// Fetch All Employee Records whose first name is John<br>employees = dbconnection.Query&lt;Employee&gt;(&quot;SELECT * FROM Employee WHERE FirstName = &#39;John&#39;&quot;);<br>// OR<br>employees = dbconnection.Query&lt;Employee&gt;(&quot;SELECT * FROM Employee WHERE FirstName = @Name&quot;, new { Name = &quot;John&quot; });</pre><p>As evident from this statement, it takes a lot of custom and dirty code to pass query arguments to dapper functions and keeping them embedded in the string is again an orthodox method of retrieving data from DB without gaining much benefit from the ORM. To fix this, we’ll be writing an extension which does the tedious job for us by abstracting away the dynamic object creation and exposing only numeric arguments which can be used in the query.</p><p>Let’s create an extension method on <strong>IDbConnection </strong>with the following prototype:</p><pre>static IEnumerable&lt;T&gt; Fetch&lt;T&gt;(this IDbConnection connection, string sql, params object[] args);</pre><p>This extension method will transform the parameters to a dynamic object which will eventually be passed to Dapper Function to bind the arguments to SQL Query.</p><pre>    public static class DapperExtension<br>    {<br>        public static IEnumerable&lt;T&gt; Fetch&lt;T&gt;(this IDbConnection connection, string sql, params object[] args)<br>        {<br>            return connection.Query&lt;T&gt;(sql, BuildQueryArguments(args));<br>        }<br><br>        private static object BuildQueryArguments(params object[] args)<br>        {<br>            var expandoObject = new Dictionary&lt;string, object&gt;();<br><br>            for (int i = 0; i &lt; args.Length; i++)<br>            {<br>                expandoObject.Add(i.ToString(), args[i]);<br>            }<br><br>            return expandoObject;<br>        }<br>    }</pre><p>Now, the query arguments can be addressed using numeric parameters passed in the function itself without the need to create dynamic objects for them. A sample data retrieval operation can be written as under:</p><pre><br>// Using the Dapper Extension for data retrieval<br>employees = dbconnection.Fetch&lt;Employee&gt;(&quot;SELECT * FROM Employee WHERE FirstName = @0&quot;, &quot;John&quot;);</pre><p>This extension method when used along with the Dapper Functions makes it even easier to perform common DB operations. For e.g., the IN operation can directly be written as under:</p><pre><br>// Using the Dapper Extension with Int List<br>var ageList = new List&lt;int&gt; { 22, 27, 20, 21, 26 };<br>employees = dbconnection.Fetch&lt;Employee&gt;(&quot;SELECT * FROM Employee WHERE FirstName  = @0 AND Age IN @1&quot;, &quot;John&quot;, ageList);</pre><p>This is just a shade of what can be achieved when Dapper functions work in tandem with the conventional language concepts. A lot more can be achieved if we are able to identify the pattern on how this ORM tool behaves and the extent to which the common operations can be decoupled. For the purpose of this article, I’ll keep it confined to data retrieval but will definitely be back soon with more detailed info on how it can be customized to build applications at scale and with a comparatively more decoupled approach.</p><p>I’ll be back again soon with some other segment to explore and a lot more to indulge and reflect on. Till then, keep learning and exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f97f29a5e23b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/keka-engineering/dapper-extensions-f97f29a5e23b">Dapper Extensions</a> was originally published in <a href="https://medium.com/keka-engineering">Keka Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Web App to IIS]]></title>
            <link>https://medium.com/keka-engineering/deploy-web-app-to-iis-bb2b362f086b?source=rss-b7c675922339------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb2b362f086b</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <dc:creator><![CDATA[Suyash Shukla]]></dc:creator>
            <pubDate>Sun, 08 Jan 2023 15:31:03 GMT</pubDate>
            <atom:updated>2024-11-01T11:10:46.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNZLCHWU3EF_BnwMsjJ1Fw.png" /></figure><p>Hello Everyone,</p><p>Since the advent of cloud computing and PaaS based cloud resources, a lot of configurations have been abstracted away by the cloud provider but still it acts as limiting factor when it comes to setting up your own web server.</p><p>Microsoft offers a powerful tool on windows platform which can be configured in an interactive manner to deploy web applications on Virtual Machines. In this article, we’ll be setting up our own web server using IIS.</p><p>To begin with, we need to start IIS Server and create a website under it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*anepk-OVo5lBIihYZiI4qw.png" /><figcaption>Add Website</figcaption></figure><p>In the website creation dialog, we are selecting a physical directory to which the server listens and renders the content.</p><p>Let’s quickly create a sample Dot Net Application which will eventually be deployed on Local IIS Server.</p><p>Once the application initialization is done, we’ll be creating a publish profile which would publish the built output of the code to the directory which is acting as the content source for our IIS Application.</p><blockquote>Note: In order to deploy DotNet Core application on IIS, we need to install the hosting bundle in our machine. You can download it from here: <a href="https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-aspnetcore-3.1.2-windows-hosting-bundle-installer">Download ASP.NET Core 3.1 Runtime (v3.1.2) — Windows Hosting Bundle Installer (microsoft.com)</a></blockquote><p>To publish a .NET web application, we’ll be using the Visual Studio Publish Wizard which can be accessed from Application Porject Context Menu. As a quickstart, we’ll be opting for Folder based deployment for our use case and publish the complete output directory to our IIS website content path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*57iQo9A6mtR_c1TqjYtDqQ.png" /><figcaption>Publish Profile for Folder Based Deployment in IIS</figcaption></figure><p>Once the publish profile is created, we’ll hit publish and the complete website will start rendering on the configured domain name, i.e., <strong>mywebsite.com</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l11_YZHAcjMyjCvDjL0yYQ.png" /><figcaption>Web App Publish to Project</figcaption></figure><p>Please note that in order to access the web app server over the configured domain, we need to add a host binding in our local machine. The same can done at an Intranet level as well by overriding the DNS Settings and pointing the traffic to the server origin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*artLJeoyl0KM_wtGOwD8lw.png" /><figcaption>Web Application running on IIS Server</figcaption></figure><p>That’s all for the scope of this article, this folder based deployment to IIS Website directory can be leveraged for quickly deploying the test application instances in your organizations network and many such other use cases.</p><p>IIS is a diverse tool with a large set of configuration and deployment profiles. You can explore it at length and customize your IIS Instances to a farther more extent. I’ll back again with a new article and an altogether newer dimension of technology to explore. Till then, keep learning and keep exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb2b362f086b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/keka-engineering/deploy-web-app-to-iis-bb2b362f086b">Deploy Web App to IIS</a> was originally published in <a href="https://medium.com/keka-engineering">Keka Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>