<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pritam&#039;s Blog</title>
	<atom:link href="https://www.pritambaldota.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.pritambaldota.com/</link>
	<description>cloud technology, enterprise architecture</description>
	<lastBuildDate>Sat, 09 May 2020 19:18:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8</generator>
	<item>
		<title>Logging Guidelines and Best Practices for RESTful API</title>
		<link>https://www.pritambaldota.com/logging-guidelines-and-best-practices-for-restful-api/</link>
					<comments>https://www.pritambaldota.com/logging-guidelines-and-best-practices-for-restful-api/#respond</comments>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Sat, 25 Apr 2020 06:21:18 +0000</pubDate>
				<category><![CDATA[Engineering Fundamentals]]></category>
		<category><![CDATA[best practices of instrumenting RESTful API]]></category>
		<category><![CDATA[Logging and Telemetry best guidelines]]></category>
		<guid isPermaLink="false">https://www.pritambaldota.com/?p=302</guid>

					<description><![CDATA[<p>Why logging is important Logging your code plays a very crucial role to support your service into production. Without enough logging, it becomes very difficult&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/logging-guidelines-and-best-practices-for-restful-api/">Logging Guidelines and Best Practices for RESTful API</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Why logging is important</h2>



<p>Logging your code plays a very crucial role to support your service into production. Without enough logging, it becomes very difficult to debug issues into production. </p>



<p>The support team can find difficulties to support customer issues with a lack of logging.  As a result, more problems to solve by the engineering team. Some of them can be related to invalid inputs or invalid data from customers. These problems are difficult to solve by the engineering team. Hence, loss in development productivity.</p>



<p>For example, on the e-commerce website, few customers reported that the Order Details page has issues with missing images, details, and tracking information. The sample logs recorded during Order details API call.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="787" height="239" src="/wp-content/uploads/2020/04/image-3.png" alt="poor logging techniques." class="wp-image-341" srcset="https://www.pritambaldota.com/wp-content/uploads/2020/04/image-3.png 787w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-3-300x91.png 300w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-3-768x233.png 768w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-3-769x234.png 769w" sizes="(max-width: 787px) 100vw, 787px" /></figure>



<h2 class="wp-block-heading">How to Design proper Instrumentation or logging</h2>



<p>Various aspects need to consider while instrumenting your code. For instance, correlation logs, what technology to choose, data retention, costing, and many more. But some of them are mandatory and part of fundamental engineering. These require detailed planning and thought process ahead of time.</p>



<h3 class="wp-block-heading">End to End Correlation</h3>



<p>Each API request should have a unique identifier that should be tied up with all logs statements related to this request. Correlation id or request-id are common unique identifier. The Http request receives the unique identifier in its request header.</p>



<p>For instance, you can generate GUID into the client application and send this value as an HTTP header with any key name. For instance, <strong>x-correlation-id</strong>. </p>



<figure class="wp-block-image size-large"><img decoding="async" width="579" height="192" src="/wp-content/uploads/2020/04/image-2.png" alt="Send x-correlation-id as header when calling http request." class="wp-image-309" srcset="https://www.pritambaldota.com/wp-content/uploads/2020/04/image-2.png 579w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-2-300x99.png 300w" sizes="(max-width: 579px) 100vw, 579px" /></figure>



<h3 class="wp-block-heading">Contextual Log statements</h3>



<p>Use contextual and simple log statements which will help the reader to understand the purpose of the log. For instance, while fetching order details API, you can see the following logs are easily readable.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="996" height="164" src="/wp-content/uploads/2020/04/image-4.png" alt="Contextual logs with correlation id. " class="wp-image-344" srcset="https://www.pritambaldota.com/wp-content/uploads/2020/04/image-4.png 996w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-4-300x49.png 300w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-4-768x126.png 768w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-4-769x127.png 769w" sizes="(max-width: 996px) 100vw, 996px" /></figure>



<h3 class="wp-block-heading">Different types of logs</h3>



<p>Common Log types are Informational, Verbose, Warning and Error.</p>



<figure class="wp-block-table is-style-regular"><table class="has-fixed-layout"><thead><tr><th><br>Type</th><th>Purpose</th></tr></thead><tbody><tr><td>Informational (Info)</td><td>Record the general information talks about the progress and flow of the process. For instance, Start/stop of service, intermediate checkpoints, etc. This type should be default ON into Production systems.</td></tr><tr><td>Verbose</td><td>More than General Information which records granular steps. For instance, each iteration of for loops with different parameters logged, any other system information which is only needed in specific scenarios. This type of log is not recommended to keep ON. This should be enabled only in certain circumstances where Info logs are not enough to debug. </td></tr><tr><td>Warning</td><td>Any potential warning may cause side-effects, but it will not abort the execution of process. For instance, Shipment tracking information call is failing, due to which this information cannot be shown on the order details page. But other order details are available. This kind of information should be recorded as Warning.</td></tr><tr><td>Error</td><td>Any errors/exceptions which will abort the further execution of the process. Generally, this type of logs is recorded into a try-catch() block where exception handling is needed.</td></tr></tbody></table></figure>



<p>Verbose level logging helps to discover internal issues that are not available with Informational logs. As a result, the support team can easily understand what is wrong with this order.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="283" src="/wp-content/uploads/2020/04/image-5-1024x283.png" alt="logs with best practices." class="wp-image-347" srcset="https://www.pritambaldota.com/wp-content/uploads/2020/04/image-5-1024x283.png 1024w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-5-300x83.png 300w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-5-768x213.png 768w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-5-769x213.png 769w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-5.png 1109w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Avoid Sensitive / PII (Personal Identifiable Information)</h3>



<p>Personal Identifiable Information (PII) is&nbsp;any information that can identify an individual. For instance, name, email address, telephone number, or social security number.</p>



<p>Due to Data Privacy and Compliance reasons never log any PII information of your users. You can read more about <a rel="noreferrer noopener" href="https://en.wikipedia.org/wiki/Information_privacy" target="_blank">Data Privacy</a>.</p>



<p>When logging API requests, ensure that the Authorization header is removed or replace the value with some static arbitrary value. In addition, if your API only works with Bearer token, then look for all HTTP header values, query string parameters. If any of value found with Bearer keyword, then replace this value. This approach will help if by mistake caller provided incorrect header key with the bearer token. As a result, a bearer token can be present in the logs. Hence, your logs can flag for non-compliance.   </p>



<h2 class="wp-block-heading">Application Monitoring Tools</h2>



<p>These days various options available for instrumenting your code. For instance, <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview" target="_blank">Microsoft Application Insights</a>, <a rel="noreferrer noopener" href="https://newrelic.com/" target="_blank">New Relic</a>, <a rel="noreferrer noopener" href="https://www.appdynamics.com/" target="_blank">AppDynamics </a>any many more. To abstract your instrumentation technology, you can choose any of these tools which suit your requirements.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Anyone from the team should be able to identify the production issue in less than 5 minutes from logs. If your team can achieve this, then you are following best practices for instrumenting your code.</p>



<p>Happy Logging. <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a href="https://www.pritambaldota.com/logging-guidelines-and-best-practices-for-restful-api/">Logging Guidelines and Best Practices for RESTful API</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.pritambaldota.com/logging-guidelines-and-best-practices-for-restful-api/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Load Test Web API in just 5 minutes without any testing tool</title>
		<link>https://www.pritambaldota.com/how-to-load-test-web-api-in-just-5-minutes-without-any-testing-tool/</link>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Sat, 04 Apr 2020 18:10:44 +0000</pubDate>
				<category><![CDATA[Load Testing]]></category>
		<category><![CDATA[Api Load Testing]]></category>
		<category><![CDATA[Azure Web App]]></category>
		<category><![CDATA[load test api in 5 min]]></category>
		<guid isPermaLink="false">http://www.pritambaldota.com/?p=273</guid>

					<description><![CDATA[<p>The Problem Testing REST (Representational State Transfer) Api is very common task for any organization. Ideally, dedicated test team or automation runs to do api&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/how-to-load-test-web-api-in-just-5-minutes-without-any-testing-tool/">How to Load Test Web API in just 5 minutes without any testing tool</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">The Problem</h2>



<p>Testing <a rel="noreferrer noopener" href="https://en.wikipedia.org/wiki/Representational_state_transfer" target="_blank">REST </a>(Representational State Transfer) Api is very common task for any organization. Ideally, dedicated test team or automation runs to do api test after development. But during development most of the time developer test with small set of data. What if we want to test for massive data, like millions of request? This can be easily achieve in less than 5 min without any special test tool. </p>



<p>Design your Api&#8217;s to handle load during peak hours, so performing load test is essential. For instance, 10000 requests/minute or 200 requests/second can generate millions of request load on server.</p>



<h2 class="wp-block-heading">The Solution</h2>



<p>To perform load test, we have to use some automated load tools. There are several free/paid tools available. These tools comes with lot of great features which involve learning time and cost. </p>



<p>What if we can achieve the purpose without using any specific testing tools? Yes, we can do it very easily in any programming language. I am showing example using C#. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Save every single penny wherever possible.</p><cite>&#8211; General thought</cite></blockquote>



<p>To load test, rationale is very simple &#8211; </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Send thousands of  web requests simultaneously.</p><cite>&#8211; Millions of Web Request</cite></blockquote>



<h2 class="wp-block-heading">How to implement the solution</h2>



<p>We can do this in simple C# console App or <a rel="noreferrer noopener" href="https://www.linqpad.net/" target="_blank">Linqpad</a> (great tool for .Net developer) with <a rel="noreferrer noopener" href="https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient" target="_blank">HttpClient</a> in just 5 minutes. I am using Linqpad to run this script.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">void Main()
{
    System.Threading.Tasks.Task.Run(async () =>
    {
        "Start Generating Load".Dump();
        await RunTest();
        "Completed.".Dump();
    });
}

public async System.Threading.Tasks.Task RunTest()
{
	int MAX_ITERATIONS = 500;
	int MAX_PARALLEL_REQUESTS = 500;
	int DELAY = 100;
	
	// Collection of Url's to test. Change to your valid Url's.
    string[] urls = new string[] { "https://hostname.azurewebsites.net/api/datatest", "https://hostname.azurewebsites.net/api/datatest/add" };
	
    using (var httpClient = new System.Net.Http.HttpClient())
    {
		// To add any headers like Bearer Token, Media Type etc.
        //httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxxx");
		
        for (var step = 1; step &lt; MAX_ITERATIONS; step++)
        {
            $"Started iteration: {step}".Dump();
            var tasks = new List&lt;System.Threading.Tasks.Task&lt;System.Net.Http.HttpResponseMessage>>();
            for (int i = 0; i &lt; MAX_PARALLEL_REQUESTS; i++)
            {
                tasks.Add(httpClient.PostAsync(urls[i % 2], null));
            }

			// Run all 300 tasks in parallel
            var result = await System.Threading.Tasks.Task.WhenAll(tasks);

            $"Completed Iteration: {step}".Dump();
			
			// Some delay before new iteration
            await System.Threading.Tasks.Task.Delay(DELAY);
        }
    }
}</pre>



<p>I ran this script for 500 iterations from 300 to 1000 parallel request per iteration for few hours. The web api  was developed on .Net Core 3.1, hosted on Azure Linux Web App B1 plan. You can look for another post on why to host on linux web app over windows &#8211; <a rel="noreferrer noopener" href="http://www.pritambaldota.com/deploy-asp-net-core-apps-to-azure-app-service-with-lesser-cost/" target="_blank">Deploy ASP.NET Core apps to Azure App Service with lesser cost </a>, which is why I chose Linux Web App over Windows. The test script was able to generate 2 millions of requests successfully from my Surface Book within few hours.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="499" src="/wp-content/uploads/2020/04/image-1-1024x499.png" alt="Load Test result on Azure Linux Web App B1 plan. " class="wp-image-278" srcset="https://www.pritambaldota.com/wp-content/uploads/2020/04/image-1-1024x499.png 1024w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-1-300x146.png 300w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-1-768x374.png 768w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-1-1536x748.png 1536w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-1-2048x998.png 2048w, https://www.pritambaldota.com/wp-content/uploads/2020/04/image-1-769x375.png 769w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption>Avg. 13000 API web request/minutes load</figcaption></figure>



<h2 class="wp-block-heading">Conclusion</h2>



<p>To summarize, we should always test our code for performance, scale, which results into better quality code.  </p>



<p>I hope you found this post helpful. </p>
<p>The post <a href="https://www.pritambaldota.com/how-to-load-test-web-api-in-just-5-minutes-without-any-testing-tool/">How to Load Test Web API in just 5 minutes without any testing tool</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Reading string content from Azure Blob Storage using CSharp (C#)</title>
		<link>https://www.pritambaldota.com/reading-string-content-from-azure-blob-storage-using-csharp/</link>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Sun, 16 Feb 2020 23:14:36 +0000</pubDate>
				<category><![CDATA[.Net Core]]></category>
		<category><![CDATA[Azure Blob Storage]]></category>
		<category><![CDATA[Azure Cloud]]></category>
		<category><![CDATA[Azure Blob Storage .net client library]]></category>
		<category><![CDATA[read azure blob content in .net]]></category>
		<category><![CDATA[read csv from azure blob storage in C#]]></category>
		<category><![CDATA[Reading string content from Azure Blob Storage using C# (CSharp)]]></category>
		<guid isPermaLink="false">http://pritambaldota.com/?p=249</guid>

					<description><![CDATA[<p>How to read string content from Azure Blob Storage using CSharp (C#) is very common scenario. For e.g if you want to read CSV blob.&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/reading-string-content-from-azure-blob-storage-using-csharp/">Reading string content from Azure Blob Storage using CSharp (C#)</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>How to read string content from Azure Blob Storage using CSharp (C#) is very common scenario. For e.g if you want to read CSV blob.  Azure Blob storage .Net client library v12 is recommended package, but there is no direct API to achieve this easily.</p>



<p>Microsoft released <a rel="noreferrer noopener" aria-label="Azure Blob storage client library v12 for .NET (opens in a new tab)" href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet" target="_blank">Azure Blob storage client library v12 for .NET</a> which is recommended library to work with Azure blob storage going forward. This new SDK is refactored into specific nuget packages based on resources. For e.g. if you want to work with Azure Blob Storage then use <a rel="noreferrer noopener" aria-label="Microsoft.Azure.Storage.Blob (opens in a new tab)" href="https://www.nuget.org/packages/Microsoft.Azure.Storage.Blob/" target="_blank">Microsoft.Azure.Storage.Blob</a> .Net Client package. You can install this via  <strong>dotnet add package Microsoft.Azure.Storage.Blob </strong>command. This package has differences in API signatures as compared to earlier <a rel="noreferrer noopener" aria-label="legacy v11 SDK (opens in a new tab)" href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet-legacy" target="_blank">legacy v11 SDK</a>.</p>



<p>To read serialized string content from blob, there is no direct API available for e.g. reading CSV content line by line. Instead of serialized string, the API will return response content Memory Stream. You can use <a rel="noreferrer noopener" aria-label="StreamReader  (opens in a new tab)" href="https://docs.microsoft.com/en-us/dotnet/api/system.io.streamreader?view=netcore-3.1" target="_blank">StreamReader </a>Api to read the stream at ones or line by line easily with  <a rel="noreferrer noopener" aria-label="ReadLineAsync() (opens in a new tab)" href="https://docs.microsoft.com/en-us/dotnet/api/system.io.streamreader.readlineasync?view=netcore-3.1#System_IO_StreamReader_ReadLineAsync" target="_blank">ReadLineAsync()</a> or <a rel="noreferrer noopener" aria-label="ReadToEndAsync() (opens in a new tab)" href="https://docs.microsoft.com/en-us/dotnet/api/system.io.streamreader.readtoendasync?view=netcore-3.1" target="_blank">ReadToEndAsync()</a> api from StreamReader class from <a href="https://docs.microsoft.com/en-us/dotnet/api/system.io?view=netcore-3.1">System.IO</a> namespace.</p>



<p> The Microsoft.Azure.Stroage.Blob SDK provides  the&nbsp;<a href="https://docs.microsoft.com/en-us/dotnet/api/azure.storage.blobs.blobserviceclient?view=azure-dotnet">BlobServiceClient</a>&nbsp;which allows you to manipulate Azure Storage service resources and blob containers.   </p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">BlobServiceClient blobServiceClient = new BlobServiceClient("connectionString");</pre>



<p>Once you get reference of BlobServiceClient, you can call GetBlobContainerClient() api from blob service client object to get the <a rel="noreferrer noopener" aria-label="BlobContainerClient (opens in a new tab)" href="https://docs.microsoft.com/en-us/dotnet/api/azure.storage.blobs.blobcontainerclient?view=azure-dotnet" target="_blank">BlobContainerClient</a> which  allows you to manipulate Azure Storage containers and their blobs. </p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("containerName");</pre>



<p>After you get BloblContainerClient, you can get reference of specific blob by GetBlobClient() Api which create a new&nbsp;<a href="https://docs.microsoft.com/en-us/dotnet/api/azure.storage.blobs.blobclient?view=azure-dotnet">BlobClient</a>&nbsp;object by appending&nbsp;<code>blobName</code>&nbsp;to the end of&nbsp;<a href="https://docs.microsoft.com/en-us/dotnet/api/azure.storage.blobs.blobcontainerclient.uri?view=azure-dotnet#Azure_Storage_Blobs_BlobContainerClient_Uri">Uri</a>. </p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">BlobClient blobClient = containerClient.GetBlobClient("blobName.csv");</pre>



<p>You can later call DownloadAsyn() method on BlobClient to download the blob Response Stream, which you can read by StreamReader.ReadLineAsyn() api. </p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">var response = await blobClient.DownloadAsync();
  using (var streamReader= new StreamReader(response.Value.Content))
  {
    while (!streamReader.EndOfStream)
    {
      var line = await streamReader.ReadLineAsync();
      Console.WriteLine(line);
    }
  }</pre>



<p>Complete source code will be as below &#8211;</p>



<pre class="EnlighterJSRAW" data-enlighter-language="csharp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">BlobServiceClient blobServiceClient = new BlobServiceClient("connectionString");
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("containerName");
BlobClient blobClient = containerClient.GetBlobClient("blobName.csv");
if (await blobClient.ExistsAsync())
{
  var response = await blobClient.DownloadAsync();
  using (var streamReader= new StreamReader(response.Value.Content))
  {
    while (!streamReader.EndOfStream)
    {
      var line = await streamReader.ReadLineAsync();
      Console.WriteLine(line);
    }
  }
}</pre>



<p>Hopefully, this article helped you figure out how to get this working. </p>
<p>The post <a href="https://www.pritambaldota.com/reading-string-content-from-azure-blob-storage-using-csharp/">Reading string content from Azure Blob Storage using CSharp (C#)</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Deploy ASP.NET Core apps to Azure App Service with lesser cost</title>
		<link>https://www.pritambaldota.com/deploy-asp-net-core-apps-to-azure-app-service-with-lesser-cost/</link>
					<comments>https://www.pritambaldota.com/deploy-asp-net-core-apps-to-azure-app-service-with-lesser-cost/#comments</comments>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Thu, 13 Feb 2020 03:40:57 +0000</pubDate>
				<category><![CDATA[.Net Core]]></category>
		<category><![CDATA[Azure Cloud]]></category>
		<category><![CDATA[Cost Optimization]]></category>
		<category><![CDATA[cost optimization azure]]></category>
		<category><![CDATA[deploy to azure web app with linux]]></category>
		<category><![CDATA[save money with azure web app]]></category>
		<guid isPermaLink="false">http://pritambaldota.com/?p=234</guid>

					<description><![CDATA[<p>When we think of ASP.Net apps, we generally think to host on Azure web Apps on windows OS. Which is awesome and very easy to&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/deploy-asp-net-core-apps-to-azure-app-service-with-lesser-cost/">Deploy ASP.NET Core apps to Azure App Service with lesser cost</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When we think of ASP.Net apps, we generally think to host on Azure web Apps on <strong>windows</strong> <strong>OS</strong>. Which is awesome and very easy to manage from <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://portal.azure.com" target="_blank">Azure Portal</a>. But this OS comes with extra cost due to licensing.    </p>



<p>With ASP.Net Core Microsoft enabled us to run these apps on non-Windows OS platforms like Linux, MacOs. If we explore the <a rel="noreferrer noopener" aria-label="Azure App Services Pricing (opens in a new tab)" href="https://azure.microsoft.com/en-us/pricing/details/app-service/windows/" target="_blank">Azure App Services Pricing</a> and choose Linux OS, then they are almost 30-60% cheaper than the Windows OS pricing based on selected Tiers (Basic/Standard/Premium etc.).</p>



<p>For e.g. Azure App Service with Windows OS with Basic plan charges 55$ per month.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="521" src="/wp-content/uploads/2020/02/image-1024x521.png" alt="" class="wp-image-236" srcset="https://www.pritambaldota.com/wp-content/uploads/2020/02/image-1024x521.png 1024w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-300x153.png 300w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-768x391.png 768w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-1536x782.png 1536w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-2048x1042.png 2048w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-769x391.png 769w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption><a href="https://azure.microsoft.com/en-us/pricing/details/app-service/windows/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">Azure Windows app service plans pricing</a></figcaption></figure>



<p>Whereas, if you choose Linux OS with Basic plan which charges 13$ (Promotional), Standard plan is slight lesser i.e. 4$ less, <strong>Premium Plan is almost 50% lesser</strong> than Windows OS. </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="579" src="/wp-content/uploads/2020/02/image-1-1024x579.png" alt="" class="wp-image-237" srcset="https://www.pritambaldota.com/wp-content/uploads/2020/02/image-1-1024x579.png 1024w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-1-300x170.png 300w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-1-768x434.png 768w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-1-1536x868.png 1536w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-1-2048x1157.png 2048w, https://www.pritambaldota.com/wp-content/uploads/2020/02/image-1-769x435.png 769w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption><a rel="noreferrer noopener" aria-label="Azure Linux app service plans pricing (opens in a new tab)" href="https://azure.microsoft.com/en-us/pricing/details/app-service/linux/" target="_blank">Azure Linux app service plans pricing</a></figcaption></figure>



<p>Cost plays very crucial roles for any Organization, specially when it is startup where every single penny worth to save. I have worked with several startups and had first hand experience on how cost impacts with time. Specially when startups joins Microsoft BizSpark kind of programs where they get free unlimited credits for certain period, which gives us opportunity to focus on business/technology and not worry on infrastructure cost. But at the end of program they end up using over provisioned resources which lands them into huge monthly bills. </p>



<p>We should do proper capacity planning on costing by evaluating alternatives which will save money. </p>



<p>We may not get all the features of Windows  OS hosting vs hosting on Linux OS, but there are always workarounds. From feature parity we can achieve everything regardless of what will be our host OS.     </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>We should be always careful when we choose the resources even though they are free. </p></blockquote>



<p>You can read more on  <a href="https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-intro">Azure App Service on Linux</a>. </p>
<p>The post <a href="https://www.pritambaldota.com/deploy-asp-net-core-apps-to-azure-app-service-with-lesser-cost/">Deploy ASP.NET Core apps to Azure App Service with lesser cost</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.pritambaldota.com/deploy-asp-net-core-apps-to-azure-app-service-with-lesser-cost/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Enabling HTTPS on localhost when running Create React App (CRA) locally</title>
		<link>https://www.pritambaldota.com/enabling-https-on-localhost-when-running-create-react-app-cra-locally/</link>
					<comments>https://www.pritambaldota.com/enabling-https-on-localhost-when-running-create-react-app-cra-locally/#respond</comments>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Thu, 23 Jan 2020 23:58:58 +0000</pubDate>
				<category><![CDATA[React]]></category>
		<category><![CDATA[Create react app]]></category>
		<category><![CDATA[enable https on localhost]]></category>
		<category><![CDATA[run react app on https]]></category>
		<category><![CDATA[test react app with SSL]]></category>
		<guid isPermaLink="false">http://pritambaldota.com/?p=188</guid>

					<description><![CDATA[<p>Create React App (CRA) is convenient and easy way to setup initial boiler plate when developing React App. To start building React App using CRA,&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/enabling-https-on-localhost-when-running-create-react-app-cra-locally/">Enabling HTTPS on localhost when running Create React App (CRA) locally</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><a rel="noreferrer noopener" aria-label="Create React App (CRA) (opens in a new tab)" href="https://reactjs.org/docs/create-a-new-react-app.html" target="_blank">Create React App (CRA)</a> is convenient and easy way to setup initial boiler plate when developing React App. </p>



<p>To start building React App using CRA, we generally use following steps to start setup and run default CRA app.</p>



<pre class="wp-block-code"><code>npx create-react-app my-app
cd my-app
npm start</code></pre>



<p>After running these steps we will generally see the React app running locally on http://localhost:3000. But when we deploy and run app on production we mostly host on <strong>HTTPS</strong>. So, the question is how do we test the app locally on https. </p>



<p>This is very easy to setup, just run Set HTTPS=true before running npm start or yarn start. Alternavely you can update the npm scripts into packages.json </p>



<p> &#8220;start&#8221;: &#8220;<strong>set HTTPS=true&amp;</strong>react-scripts start&#8221;</p>



<p>When we run npm start or yarn start we will see React app will launched on https://localhost:3000. </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="988" height="1024" src="/wp-content/uploads/2020/01/image-1-988x1024.png" alt="Enabling HTTPS on localhost when running Create React App (CRA) locally" class="wp-image-196" srcset="https://www.pritambaldota.com/wp-content/uploads/2020/01/image-1-988x1024.png 988w, https://www.pritambaldota.com/wp-content/uploads/2020/01/image-1-289x300.png 289w, https://www.pritambaldota.com/wp-content/uploads/2020/01/image-1-768x796.png 768w, https://www.pritambaldota.com/wp-content/uploads/2020/01/image-1-1482x1536.png 1482w, https://www.pritambaldota.com/wp-content/uploads/2020/01/image-1.png 1525w" sizes="auto, (max-width: 988px) 100vw, 988px" /></figure>



<p></p>
<p>The post <a href="https://www.pritambaldota.com/enabling-https-on-localhost-when-running-create-react-app-cra-locally/">Enabling HTTPS on localhost when running Create React App (CRA) locally</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.pritambaldota.com/enabling-https-on-localhost-when-running-create-react-app-cra-locally/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>The request body did not contain the specified number of bytes. Got 0, expected xxx &#8211; Internet Explorer Issue</title>
		<link>https://www.pritambaldota.com/the-request-body-did-not-contain-the-specified-number-of-bytes-got-0-expected-xxx-internet-explorer-issue/</link>
					<comments>https://www.pritambaldota.com/the-request-body-did-not-contain-the-specified-number-of-bytes-got-0-expected-xxx-internet-explorer-issue/#respond</comments>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Fri, 19 Jun 2015 23:56:17 +0000</pubDate>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[re-post error]]></category>
		<guid isPermaLink="false">http://www.pritambaldota.com/?p=135</guid>

					<description><![CDATA[<p>When you try to re-POST subsequent requests from Internet Explorer browser it only sends only the header data is posted. As a result you will&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/the-request-body-did-not-contain-the-specified-number-of-bytes-got-0-expected-xxx-internet-explorer-issue/">The request body did not contain the specified number of bytes. Got 0, expected xxx &#8211; Internet Explorer Issue</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When you try to re-POST subsequent requests from Internet Explorer browser it only sends only the header data is posted. As a result you will receive error in response &#8211; <strong>The request body did not contain the specified number of bytes. Got 0, expected xxx</strong>. There is already a Hotfix available at Microsoft Knowledge Base <a href="https://support.microsoft.com/en-gb/kb/895954" target="_blank" rel="noopener noreferrer">https://support.microsoft.com/en-gb/kb/895954</a>.</p>
<p><strong>General Repro Steps &#8211;</strong></p>
<ol>
<li>For every first XMLHttpRequest, a keep alive connection (TCP Connection) is created which is used by any subsequent request. If the connection is forcibly closed by the browser, then browsers will try to create a new connection by resubmitting the request.</li>
<li>For GET Requests it will work without any issues. But for POST it will only send Request Headers and not the body in Internet Explorer. That&#8217;s why you will receive error &#8211; <strong>The request body did not contain the specified number of bytes. Got 0, expected xxx</strong>.</li>
<li>As a solution either install above mentioned Hotfix or Use NEW unique URL by adding TimeStamp to URL to avoid any re-POST request.</li>
</ol>
<p>For e.g.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="js">var urlToPost = "ajaxUrlToPost.svc?stamp=' + new Date().getTime();</pre>
<p>The post <a href="https://www.pritambaldota.com/the-request-body-did-not-contain-the-specified-number-of-bytes-got-0-expected-xxx-internet-explorer-issue/">The request body did not contain the specified number of bytes. Got 0, expected xxx &#8211; Internet Explorer Issue</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.pritambaldota.com/the-request-body-did-not-contain-the-specified-number-of-bytes-got-0-expected-xxx-internet-explorer-issue/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SharePoint 2010/2013 Date Comparison in different Time Zones</title>
		<link>https://www.pritambaldota.com/sharepoint-2010-2013-date-comparison-in-different-time-zones/</link>
					<comments>https://www.pritambaldota.com/sharepoint-2010-2013-date-comparison-in-different-time-zones/#respond</comments>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Wed, 03 Jun 2015 23:55:48 +0000</pubDate>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[SharePoint 2013]]></category>
		<category><![CDATA[Date Operation in different time zones]]></category>
		<category><![CDATA[DateTime Conversion in SharePoint]]></category>
		<category><![CDATA[Sharepoint 2010]]></category>
		<category><![CDATA[sharepoint 2013]]></category>
		<guid isPermaLink="false">http://www.pritambaldota.com/?p=123</guid>

					<description><![CDATA[<p>Working with DateTime in SharePoint is always tricky since it stores values internally in UTC and when we tried to access it in CSOM or&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/sharepoint-2010-2013-date-comparison-in-different-time-zones/">SharePoint 2010/2013 Date Comparison in different Time Zones</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Working with DateTime in SharePoint is always tricky since it stores values internally in UTC and when we tried to access it in CSOM or SOM in different Time zone we have to be very careful while filtering on Created, Modified Date columns.</p>
<p>Time Zone plays very crucial roles in any Date Time difference calculation. When we do difference in two date times, it must be in same Time Zone offset otherwise the result will never be correct. Here, <a href="https://msdn.microsoft.com/en-us/library/system.timezoneinfo(v=vs.110).aspx" target="_blank" rel="noopener noreferrer">TimeZoneInfo</a> class plays main role. To get specific time zone details we have to use <a href="https://msdn.microsoft.com/en-us/library/system.timezoneinfo.findsystemtimezonebyid(v=vs.110).aspx" target="_blank" rel="noopener noreferrer">TimeZoneInfo.FindSystemTimeZoneById</a> method which will take input of Zone Id. All available Time Zone Id&#8217;s can be found at MSDN <a href="https://msdn.microsoft.com/en-us/library/gg154758.aspx" target="_blank" rel="noopener noreferrer">https://msdn.microsoft.com/en-us/library/gg154758.aspx</a>.</p>
<p>To explain this problem lets take a example that we need to find all SharePoint List items which was created in last 5 minutes.</p>
<p>First we will retrieve all Items from a List which is created Today. We will use CAML Query to get these items.</p>


<pre class="wp-block-code"><code>// Store result in temporary Table
DataTable dataResult = new DataTable();
dataResult.Columns.Add("ID");
dataResult.Columns.Add("Title");

//Get List Data
SPWeb sbWeb = SPContext.Current.Site.RootWeb;
SPList list = sbWeb.GetList("MyCustomList");
SPQuery listQuery = new SPQuery();

// Get items for todays date
listQuery.Query = "&lt;Where>&lt;Eq>&lt;FieldRef Name='Created' />&lt;Value Type='DateTime'>&lt;Today />&lt;/Value>&lt;/Eq>&lt;/Where>";
SPListItemCollection items = list.GetItems(listQuery);</code></pre>



<p>Iterate through each list item and perform Date time conversion.</p>



<pre class="wp-block-code"><code>foreach(SPListItem item in items) {
	if (item&#91;“Title”] != null &amp;&amp; item&#91;“ID”] != null) {

		// Get UTC Now Date Time
		DateTime utcNowDate = new DateTime(DateTime.UtcNow.Ticks, DateTimeKind.Utc);

		// Find the Server Time Zone Info which is configured under Central Administration -> Web Application -> General Settings
		TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(“Pacific Standard Time”);

		// Convert UTC Now Date Time to server’s Time Zone i.e. into Pacific Standard Time in our example.
		DateTime convertedUtcNowDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcNowDate, timeZoneInfo);

		// Find the Date time difference into TimeSpan
		TimeSpan diffResult = convertedUtcNowDateTime–Convert.ToDateTime(item&#91;“Created”]);

		// Create 5 Minutes Time Span object
		TimeSpan fiveMinutesSpan = new TimeSpan(0, 5, 0);

		// Compare method will return -1 if first time interval is shorter than second and return 0 if both time interval are equal. Read more about this at https://msdn.microsoft.com/en-us/library/system.timespan.compare(v=vs.110).aspx
		int result = TimeSpan.Compare(diffResult, fiveMinutesSpan);

		// If result is 0 Or -1 it means items is created in last five minutes.
		if (a &lt; 1) {
			DataRow row = dataResult.NewRow();
			row&#91;"Title"] = item&#91;SPBuiltInFieldId.EncodedAbsUrl].ToString();
			row&#91;"ID"] = item&#91;ColumnName.ReportUrl].ToString();
			data.Rows.Add(dr);
		}
	}
}</code></pre>



<p> Resulting DataTable will have the filtered result. </p>
<p>The post <a href="https://www.pritambaldota.com/sharepoint-2010-2013-date-comparison-in-different-time-zones/">SharePoint 2010/2013 Date Comparison in different Time Zones</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.pritambaldota.com/sharepoint-2010-2013-date-comparison-in-different-time-zones/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>jQuery based Resource Localization</title>
		<link>https://www.pritambaldota.com/jquery-based-resource-localization/</link>
					<comments>https://www.pritambaldota.com/jquery-based-resource-localization/#respond</comments>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Sun, 31 May 2015 10:17:00 +0000</pubDate>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[SharePoint 2013]]></category>
		<category><![CDATA[jquery resources localization]]></category>
		<category><![CDATA[localization in javascript]]></category>
		<category><![CDATA[sharepoint localization in jquery]]></category>
		<category><![CDATA[web application localization in jquery]]></category>
		<guid isPermaLink="false">http://www.pritambaldota.com/?p=119</guid>

					<description><![CDATA[<p>Create client side (JavaScript) based Resource Localization in any web application. Extremely light-weight library, just 3KB (Minified) and 8KB(Debug) version. Implementing client side localization into&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/jquery-based-resource-localization/">jQuery based Resource Localization</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Create client side (JavaScript) based Resource Localization in any web application. Extremely light-weight library, just 3KB (Minified) and 8KB(Debug) version.</p>
<p>Implementing client side localization into any web application is always challenge. Most of web technologies provide localization using server-side technologies. For e.g. .Net application uses Resources Files(.resx) to implement localization into globalization application.</p>
<p>Nowadays world is extensively moving towards Asynchronous development models like AJAX / SPA. Several frameworks, libraries are already available on the web. To access these server side resources requires custom REST services / handlers to be additionally implemented into the host application.</p>
<p>This plugin makes life easier where you can manage all your localized resources into plain Text or JavaScript file. Based on current culture provided to this plugin, it loads associated resource entries for use. To enhance performance it Cache data for subsequent Initialization calls. So now no more server side development required for managing localization. It can be used in any web applications like SharePoint On-Premise / Online, Php, ASP.Net MVC, JAVA and many more as long as these technologies supports JavaScript.</p>
<p>Download Pugin from Github <a href="https://github.com/pritambaldota/jQuery-Resource-Localization" target="_blank">Github</a>.</p>
<p>Install via <a href="https://www.nuget.org/packages/PritamBaldota.JqueryResourceLocalization/" target="_blank">Nuget Package</a>.</p>
<p>The post <a href="https://www.pritambaldota.com/jquery-based-resource-localization/">jQuery based Resource Localization</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.pritambaldota.com/jquery-based-resource-localization/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JQuery Culture Information Plugin</title>
		<link>https://www.pritambaldota.com/jquery-culture-information-plugin/</link>
					<comments>https://www.pritambaldota.com/jquery-culture-information-plugin/#respond</comments>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Sat, 30 May 2015 04:24:12 +0000</pubDate>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[javascript locale]]></category>
		<category><![CDATA[Jquery culture information plugin]]></category>
		<category><![CDATA[LCID Culture]]></category>
		<guid isPermaLink="false">http://www.pritambaldota.com/?p=104</guid>

					<description><![CDATA[<p>Accessing Culture Information for all available cultures in JavaScript is always difficult and most of the web developer has to search on internet for this&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/jquery-culture-information-plugin/">JQuery Culture Information Plugin</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Accessing Culture Information for all available cultures in JavaScript is always difficult and most of the web developer has to search on internet for this information. There may be several options available to fetch this information into Server-side technologies like ASP.Net, JAVA, PHP, and etc. But in JavaScript it is very difficult to find this information at one place.</p>
<p>To solve this problem, I have created small jQuery plugin which will give you this information at one place. You can search for Culture information by LCID (for e.g. 1033) or by Culture Name (for e.g. en-US), which will return you JSON Object. This plugin can be used in any of your favorite application which supports JavaScript.</p>
<ol>
<li>Refer to the Github Project <a href="https://github.com/pritambaldota/Jquery-Culture-Info" target="_blank">JQuery Culture Information Plugin</a> </li>
<li>Install via the <a href="https://www.nuget.org/packages/PritamBaldota.JqueryCultureInfo" target="_blank">NuGet Package</a> <strong>Install-Package PritamBaldota.JqueryCultureInfo</strong></li>
</ol>
<p>Sharing is Caring <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a href="https://www.pritambaldota.com/jquery-culture-information-plugin/">JQuery Culture Information Plugin</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.pritambaldota.com/jquery-culture-information-plugin/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Associate Custom Content Type with SharePoint 2010/2013 List Or Library using PowerShell</title>
		<link>https://www.pritambaldota.com/associate-custom-content-type-with-sharepoint-2010-2013-list-or-library-using-powershell/</link>
					<comments>https://www.pritambaldota.com/associate-custom-content-type-with-sharepoint-2010-2013-list-or-library-using-powershell/#respond</comments>
		
		<dc:creator><![CDATA[Pritam Baldota]]></dc:creator>
		<pubDate>Tue, 19 May 2015 04:44:57 +0000</pubDate>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[SharePoint 2010]]></category>
		<category><![CDATA[SharePoint 2013]]></category>
		<category><![CDATA[content types]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Sharepoint 2010]]></category>
		<category><![CDATA[sharepoint 2013]]></category>
		<guid isPermaLink="false">http://www.pritambaldota.com/?p=89</guid>

					<description><![CDATA[<p>To automate deployment in SharePoint 2010/2013 on-premise solution, we have to use PowerShell. One of the deployment activity is creating SharePoint Custom Lists/Libraries and associating&#8230;</p>
<p>The post <a href="https://www.pritambaldota.com/associate-custom-content-type-with-sharepoint-2010-2013-list-or-library-using-powershell/">Associate Custom Content Type with SharePoint 2010/2013 List Or Library using PowerShell</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>To automate deployment in SharePoint 2010/2013 on-premise solution, we have to use PowerShell. One of the deployment activity is creating SharePoint Custom Lists/Libraries and associating them with custom created content types. In this article we will be focusing only how to add/remove content types from the List/Library.</p>
<p><strong>To add content type follow below steps &#8211;</strong></p>
<ul>
<li>Get Reference to Site collection and root web to get the content types.</li>
</ul>
<p>[shell]</p>
<p>$siteRef = Get-SPSite http://domain/site<br />
$rootWebRef = $siteRef.RootWeb</p>
<p>[/shell]</p>
<ul>
<li>Get the target web reference to which content type will be added for List/Library.</li>
</ul>
<p>[shell]<br />
$web = Get-SPWeb http://domain/site/web<br />
[/shell]</p>
<ul>
<li>Get the reference to target list / library</li>
</ul>
<p>[shell]<br />
$listRef = $web.Lists[&#8220;List Title&#8221;]<br />
[/shell]</p>
<ul>
<li>Enable the management of content type for this list/library.</li>
</ul>
<p>[shell]</p>
<p>$listRef.ContentTypesEnabled  = $true<br />
$listRef.Update()</p>
<p>[/shell]</p>
<ul>
<li>Get the deployed Content Type reference from root web which will be added to the target list.</li>
</ul>
<p>[shell]<br />
$targetContentType= $rootWebRef.ContentTypes[&#8220;CustomContentType&#8221;]<br />
[/shell]</p>
<ul>
<li>Check if Content is already exists from ContentTypes collection of a List. If not found then add the content type to the list.</li>
</ul>
<p>[shell]<br />
$contentTypeExist = $listRef.ContentTypes[$contentType.Name]<br />
if($contentTypeExist -ne $null)<br />
{<br />
$listRef.ContentTypes.Add($targetContentType)<br />
$listRef.Update()<br />
}<br />
[/shell]</p>
<p><strong>To delete content type follow below steps &#8211;</strong></p>
<p>To delete content type association from list, we have to get the reference of associated content type and pass the Id of content type to Delete method on ContentTypes collection.</p>
<p>[shell]</p>
<p>$contentTypeExist = $listRef.ContentTypes[$contentType.Name]</p>
<p>$listRef.ContentTypes.Delete($contentTypeExist.Id)</p>
<p>[/shell]</p>
<p><strong>This is how the complete code will look like &#8211;</strong></p>
<p>[shell]</p>
<p>$siteRef = Get-SPSite http://domain/site<br />
$rootWebRef = $siteRef.RootWeb<br />
$web = Get-SPWeb http://domain/site/web</p>
<p>$listRef = $web.Lists[&#8220;List Title&#8221;]<br />
if ($listRef -ne $null)<br />
{<br />
$listRef.ContentTypesEnabled  = $true<br />
$listRef.Update()<br />
$targetContentType = $rootWebRef.ContentTypes[$contentType.Name]<br />
if($targetContentType -ne $null)<br />
{<br />
$contentTypeExist = $listRef.ContentTypes[$contentType.Name]<br />
if($contentTypeExist -ne $null)<br />
{<br />
Write-Host &#8220;Adding Content Type &#8211; &#8221; $targetContentType.Name -ForegroundColor Green<br />
$listRef.ContentTypes.Add($targetContentType)<br />
}<br />
else<br />
{<br />
Write-Host &#8221;  Content Type already exists &#8211; &#8221; $targetContentType.Name -ForegroundColor Green<br />
}<br />
}<br />
$listRef.Update()<br />
}</p>
<p>[/shell]</p>
<p>Happy Coding <img src="https://s.w.org/images/core/emoji/15.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>The post <a href="https://www.pritambaldota.com/associate-custom-content-type-with-sharepoint-2010-2013-list-or-library-using-powershell/">Associate Custom Content Type with SharePoint 2010/2013 List Or Library using PowerShell</a> appeared first on <a href="https://www.pritambaldota.com">Pritam&#039;s Blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.pritambaldota.com/associate-custom-content-type-with-sharepoint-2010-2013-list-or-library-using-powershell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
