<?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"><channel><title><![CDATA[Its Just the beginning..]]></title><description><![CDATA[Welcome to this blogging Site..]]></description><link>https://fasigpt.github.io</link><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Oct 2018 16:11:52 GMT</lastBuildDate><atom:link href="https://fasigpt.github.io/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Azure Devops Pipelines -unlink from your github account]]></title><description><![CDATA[<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/pipeline.gif" alt="pipeline.gif">
</div>
</div>]]></description><link>https://fasigpt.github.io/2018/10/09/Azure-Devops-Pipelines-unlink-from-your-github-account.html</link><guid isPermaLink="true">https://fasigpt.github.io/2018/10/09/Azure-Devops-Pipelines-unlink-from-your-github-account.html</guid><category><![CDATA[azure dev ops]]></category><category><![CDATA[azure pipelines]]></category><pubDate>Tue, 09 Oct 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[Azure Policy - Block storage deployment to a specifc subnet]]></title><description><![CDATA[<div class="paragraph">
<p>If you need to block storage deployment to a specifc Azure subnet, you could use the below azure policy definiton -</p>
</div>
<div class="paragraph">
<p>{
  "mode": "all",
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.Storage/storageAccounts"
        },
        {
          "field": "Microsoft.Storage/storageAccounts/networkAcls.virtualNetworkRules[*].id",
          "equals": "[parameters('subnetId')]"
        }
      ]
    },
    "then": {
      "effect": "deny"
    }
  },
  "parameters": {
    "subnetId": {
      "type": "String",
      "metadata": {
        "displayName": "Subnet Id",
        "description": "Resource Id for Subnet"
      }
    }
  }
}</p>
</div>
<div class="paragraph">
<p>If you need help on deploying the policy please visit <a href="https://docs.microsoft.com/en-us/azure/governance/policy/samples/use-approved-subnet-vm-nics" class="bare">https://docs.microsoft.com/en-us/azure/governance/policy/samples/use-approved-subnet-vm-nics</a></p>
</div>]]></description><link>https://fasigpt.github.io/2018/09/28/Use-approved-subnet-for-Storage-deployment.html</link><guid isPermaLink="true">https://fasigpt.github.io/2018/09/28/Use-approved-subnet-for-Storage-deployment.html</guid><category><![CDATA[Azure Policy]]></category><category><![CDATA[Azure Storage]]></category><category><![CDATA[Azure Subnet]]></category><pubDate>Fri, 28 Sep 2018 00:00:00 GMT</pubDate></item><item><title><![CDATA[Capture Outgoing http/https Request from web Application hosted on Azure App Service]]></title><description><![CDATA[<div class="paragraph">
<p>If you are troubleshooting any 500 Errors caused due to any form of connectivity issues with outgoing webservice/webApi calls, you often have to capture system.net trace which is very huge and time consuming to review. I am working a way to host fiddlercore as a webjob to proxy the requests, but meanwhile I have found another technique to capture these requests.</p>
</div>
<div class="literalblock">
<div class="content">
<pre> Step1:
Create an Azure VM with an inbound rule (NSG) allowing 8888 traffic</pre>
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/fiddlerproxy1.png" alt="fiddlerproxy1.png">
</div>
</div>
<div class="paragraph">
<p>Step2:</p>
</div>
<div class="paragraph">
<p>Install and Run Fiddler.
Fiddler options-HTTPS-Enable “decrypt https traffic” if you are capturing SSL traffic as well
Fiddler options-Connections- Enable “Allow remote computers to connect”</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/fiddlerproxy2.png" alt="fiddlerproxy2.png">
</div>
</div>
<div class="paragraph">
<p>Step3: Restart Fiddler</p>
</div>
<div class="paragraph">
<p>Step4: On the application side you only need to do this change, add the system.net proxy settings</p>
</div>
<div class="literalblock">
<div class="content">
<pre>  &lt;system.net&gt;
 &lt;defaultProxy&gt;
  &lt;proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://IpAddressOfYourAzureVM:8888" usesystemdefault="false" /&gt;
 &lt;/defaultProxy&gt;
&lt;/system.net&gt;</pre>
</div>
</div>
<div class="paragraph">
<p>Now, all the outgoing calls from your Azure AppService should be proxied through Fiddler running on another Azure VM.</p>
</div>]]></description><link>https://fasigpt.github.io/2017/08/12/Capture-Outgoing-httphttps-Request-from-web-Application-hosted-on-Azure-App-Service.html</link><guid isPermaLink="true">https://fasigpt.github.io/2017/08/12/Capture-Outgoing-httphttps-Request-from-web-Application-hosted-on-Azure-App-Service.html</guid><category><![CDATA[azure app service]]></category><category><![CDATA[Fiddler]]></category><category><![CDATA[Proxy]]></category><pubDate>Sat, 12 Aug 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[How IIS Bindings work in  Azure App Services and Cloud Service]]></title><description><![CDATA[<div class="paragraph">
<p>How IIS Bindings work in  Azure App Services and Cloud Service</p>
</div>
<div class="paragraph">
<p>In this blog I will try to Explain how bindings are created when you create a Azure Cloud Service and Azure Web App. In the below picture we have a Cloud Service called “contoso.cloudapp.net” and there are two instances of this service running in two different machines (Node1 and Node2).</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/binding1.png" alt="binding1.png">
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/binding2.png" alt="binding2.png">
</div>
</div>
<div class="paragraph">
<p>There is one Virtual IP (Public IP : 1.2.3.4) for the cloud service itself and each of these Nodes will have one internal IP (Node1=10.10.10.10,Node2=10.10.10.11) . Now, at the IIS level in each of these Nodes one IP:PORT binding will be created, what is important is there is no HOST NAME mapped to this binding. The HOST NAME text box above is empty as you can see in the above image.</p>
</div>
<div class="paragraph">
<p>Observations</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/binding3.png" alt="binding3.png">
</div>
</div>
<div class="paragraph">
<p>In the above observations table we can see the website will load in all scenarios as the binding is set IP:PORT and there is no HOSTNAME.Now, lets see how this defers when we use app Service.</p>
</div>
<div class="paragraph">
<p>In the below diagram we can see that when you create a app Service there will be HOSTNAME associated with the binding.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/binding4.png" alt="binding4.png">
</div>
</div>
<div class="paragraph">
<p>Observations</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/binding5.png" alt="binding5.png">
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/binding6.png" alt="binding6.png">
</div>
</div>
<div class="paragraph">
<p>The 404 error is thrown by the ARR, as it would have got internal 404 from the backend NODE rejected by http.sys (404 – NotFound) which expects the request to have HOSTHEADER matching with contoso.azurewebsites.net. Now, if you have traffic manager in front of your app service then another binding will be created with the matching HOSTNAME of your traffic manager. (Here azureAppServicehost is the site name and azuretrafficmanagerhost.trafficmanager.net is the traffic manager Host)</p>
</div>
<div class="paragraph">
<p>So technically only requests that have these two host headers will work azure app Service unlike Azure Cloud Service.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/binding7.png" alt="binding7.png">
</div>
</div>]]></description><link>https://fasigpt.github.io/2017/08/03/How-IIS-Bindings-work-in-Azure-App-Services-and-Cloud-Service.html</link><guid isPermaLink="true">https://fasigpt.github.io/2017/08/03/How-IIS-Bindings-work-in-Azure-App-Services-and-Cloud-Service.html</guid><category><![CDATA[azure]]></category><category><![CDATA[app service]]></category><category><![CDATA[cloud service]]></category><category><![CDATA[traffic manager]]></category><category><![CDATA[404]]></category><category><![CDATA[IIS binding]]></category><pubDate>Thu, 03 Aug 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Fiddler with asp.net core and configure asp.net core as a reverse proxy.]]></title><description><![CDATA[<div class="paragraph">
<p>Scenario 1: Configure Fiddler to capture outgoing requests from asp.net core process</p>
</div>
<div class="paragraph">
<p>You need to define a custom Class Implementing IWebProxy as below</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/aspnetproxy3.png" alt="aspnetproxy3.png">
</div>
</div>
<div class="paragraph">
<p>Now, you need configure HttpClientHandler in your controller with the custom class (MyHttpProxy) to feed the fiddler  proxy settings</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/aspnetproxy1.png" alt="aspnetproxy1.png">
</div>
</div>
<div class="paragraph">
<p>Now, the outgoing call from the methods should be proxied through fiddler.</p>
</div>
<div class="paragraph">
<p>Scenario2: Configure asp.net core process to act as a reverse proxy</p>
</div>
<div class="paragraph">
<p>We can run asp.net core acting as a reverse proxy, wherein it can route the requests to another backend web server. In the below diagram the client talks to asp.net core over port 443 and asp.net core routes the request  to backend service over port 80</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/aspnetproxy2.png" alt="aspnetproxy2.png">
</div>
</div>
<div class="paragraph">
<p>There are only couple of things you need to do:</p>
</div>
<div class="literalblock">
<div class="content">
<pre>Install Nuget Package “Microsoft.AspNetCore.Proxy”</pre>
</div>
</div>
<div class="paragraph">
<p>Configure the proxy middleware in the startup.cs</p>
</div>
<div class="paragraph">
<p>ProxyOptions proxyOptions = new ProxyOptions();
            proxyOptions.Host = "yourbackendserver";
            proxyOptions.Scheme = "http";
            proxyOptions.Port = "80";</p>
</div>
<div class="literalblock">
<div class="content">
<pre>app.RunProxy(proxyOptions);</pre>
</div>
</div>
<div class="paragraph">
<p>you can download the complete sample here  <a href="https://github.com/fasigpt/fiddlerwithaspnetcore" class="bare">https://github.com/fasigpt/fiddlerwithaspnetcore</a></p>
</div>]]></description><link>https://fasigpt.github.io/2017/08/02/Fiddler-with-aspnet-core-and-configure-aspnet-core-as-a-reverse-proxy.html</link><guid isPermaLink="true">https://fasigpt.github.io/2017/08/02/Fiddler-with-aspnet-core-and-configure-aspnet-core-as-a-reverse-proxy.html</guid><category><![CDATA[asp.net core]]></category><category><![CDATA[fiddler]]></category><category><![CDATA[proxy]]></category><pubDate>Wed, 02 Aug 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[asp.net core with cookie authentication in web farm scenario]]></title><description><![CDATA[<div class="paragraph">
<p>When you host your application on multiple IIS servers behind a load balancer, you must take care of storing sessions and using same machine keys on all servers to encrypt cookie and view state. When you create machine keys especially at the IIS root level, the keys are stored in the applicationhost.config file. This config file is IIS specific and only IIS process will read the configuration. In the asp.net core world, the hosting is little different, the IIS process only acts as a reverse proxy through the aspnetcoremodule.</p>
</div>
<div class="paragraph">
<p>&lt;system.webServer&gt;
    &lt;handlers&gt;
      &lt;add name="aspNetCore" path="<strong>" verb="</strong>" modules="AspNetCoreModule" resourceType="Unspecified" /&gt;
    &lt;/handlers&gt;
    &lt;aspNetCore processPath="dotnet" arguments=".\youraspnetcore.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" /&gt;
  &lt;/system.webServer&gt;</p>
</div>
<div class="paragraph">
<p>The actual process which hosts your code is dotnet.exe running behind IIS process and it cannot access apphost.config file. Because of this architecture, we provide different storage mechanisms to store the encryption keys like file system, Azure Blobs, Registry, Custom Storage (IXmlRepository EX : SQL) through the Microsoft.AspNetCore.DataProtection namespace.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/aspnetcore1.png" alt="aspnetcore1.png">
</div>
</div>
<div class="paragraph">
<p>In the above diagram, we have two IIS Servers hosting asp.net core code behind a load balancer like ARR. To configure your application to store these keys, you need to set that up in the “ConfigureServices” method.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/aspnetcore2.png" alt="aspnetcore2.png">
</div>
</div>
<div class="paragraph">
<p>The first two method will store those keys in the azure blob storage and in your local registry respectively. The file system will create the keys in a remote/local share and its basically an xml file</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/aspnetcore3.png" alt="aspnetcore3.png">
</div>
</div>]]></description><link>https://fasigpt.github.io/2017/07/30/aspnet-core-with-cookie-authentication-in-web-farm-scenario.html</link><guid isPermaLink="true">https://fasigpt.github.io/2017/07/30/aspnet-core-with-cookie-authentication-in-web-farm-scenario.html</guid><category><![CDATA[asp.net core]]></category><category><![CDATA[webfarm]]></category><pubDate>Sun, 30 Jul 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Signalr Client on Azure WebJob calling SignalR hub]]></title><description><![CDATA[<div class="paragraph">
<p>Signalr Client on Azure WebJob calling SignalR hub which is using the ServiceBus Backplane:</p>
</div>
<div class="paragraph">
<p>I have written an end to end sample that demonstrates Signalr [hosted on Azure Web Role] using the Azure ServiceBus. The Sample also includes SignalrClient hosted in Azure WebJob which calls the SignalR Hub and also a .NET Client (on prem) calling the SignalR Hub.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/SignalRPNG.PNG" alt="SignalRPNG.PNG">
</div>
</div>
<div class="paragraph">
<p>SignalR Service:</p>
</div>
<div class="paragraph">
<p>The Service has endpoint configured for Service bus inside the Startup.cs as described here <a href="https://docs.microsoft.com/en-us/aspnet/signalr/overview/performance/scaleout-with-windows-azure-service-bus" class="bare">https://docs.microsoft.com/en-us/aspnet/signalr/overview/performance/scaleout-with-windows-azure-service-bus</a> and has a ChatHub.</p>
</div>
<div class="paragraph">
<p>WebJob:</p>
</div>
<div class="paragraph">
<p>It has an async method called signalrtask which ends up calling the signalRHub (hosted on WebRole) and if you look at the WebJOb Dashboard you should see all the chat messages sent from all other clients including browser and .Net Client.</p>
</div>
<div class="literalblock">
<div class="content">
<pre>var host = new JobHost();
host.CallAsync(typeof(Functions).GetMethod("signalrtask"));</pre>
</div>
</div>
<div class="literalblock">
<div class="content">
<pre>[NoAutomaticTrigger]
public static async Task signalrtask(TextWriter log)
{
    var hubConnection = new HubConnection("http://signalrservicewebrole.cloudapp.net/");
    hubConnection.TraceLevel = TraceLevels.All;
    hubConnection.TraceWriter = Console.Out;
    IHubProxy hubProxy = hubConnection.CreateHubProxy("ChatHub");
    hubProxy.On("Send", data =&gt;
    {
       //Console.WriteLine("Incoming data: {0} {1}", data.name, data.message);
      log.WriteLine("Incoming data: {0} {1}", data.name, data.message);
    });
    await hubConnection.Start();
}</pre>
</div>
</div>
<div class="paragraph">
<p>You can view the Full Sample here <a href="https://github.com/fasigpt/webjobs-Servicebus-signalRonWebRole" class="bare">https://github.com/fasigpt/webjobs-Servicebus-signalRonWebRole</a></p>
</div>]]></description><link>https://fasigpt.github.io/2017/06/21/Signalr-Client-on-Azure-Web-Job-calling-SignalR-hub-which-is-using-the-Service-Bus-Backplane.html</link><guid isPermaLink="true">https://fasigpt.github.io/2017/06/21/Signalr-Client-on-Azure-Web-Job-calling-SignalR-hub-which-is-using-the-Service-Bus-Backplane.html</guid><category><![CDATA[WebJobs]]></category><category><![CDATA[azure]]></category><category><![CDATA[SignalR]]></category><pubDate>Wed, 21 Jun 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Asynchronous Programming -async await ConfigureAwait() deadlock]]></title><description><![CDATA[<div class="paragraph">
<p>Asynchronous Programming -async await ConfigureAwait() deadlock:</p>
</div>
<div class="paragraph">
<p>If you have not read through these below blogs on async,  then you must before you proceed!</p>
</div>
<div class="paragraph">
<p><a href="https://msdn.microsoft.com/en-us/magazine/jj991977.aspx" class="bare">https://msdn.microsoft.com/en-us/magazine/jj991977.aspx</a>
<a href="http://blog.stephencleary.com/2012/02/async-and-await.html" class="bare">http://blog.stephencleary.com/2012/02/async-and-await.html</a></p>
</div>
<div class="paragraph">
<p>Section A:
Understanding the request Flow: If you are new to this concept  then you should understand how the request flows and here is one simple example to demonstrate the same.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/async1.png" alt="async1.png">
</div>
</div>
<div class="paragraph">
<p>Everything in the above code will be executed Synchronously, till you hit the line which is decorated with “await”. The operation next to it is called “awaitable operation”  which will be asynchronous.</p>
</div>
<div class="paragraph">
<p>What happens when we hit await:
If the awaitable operation is not completed then it returns back to the caller and executes the code in the caller …(few Exceptions though, example if the caller has already been blocked by another await or Task.Wait())</p>
</div>
<div class="paragraph">
<p>If the awaitable operation is completed then the next line of code after that wait gets executed synchronously. (will discuss this later..)</p>
</div>
<div class="paragraph">
<p>To make the above sample simpler, I have added response.write to see the flow of Execution and the output that you would see here is</p>
</div>
<div class="paragraph">
<p>1, 2, 3,5,4</p>
</div>
<div class="paragraph">
<p>and it is NOT 1,2,3,4,5 because Line5 and Line6 inside getEmployeeDetailsAsync will not execute till getStudentDetailsAsync has finished executing as there is await getStudentDetailsAsync.</p>
</div>
<div class="paragraph">
<p>Section B: when to use ConfigureAwait()</p>
</div>
<div class="paragraph">
<p>Once the awaitable operation has finished, the next piece of code of that function will start executing  under  HttpContext (System.Web.HttpContext)  in an asp.net application.</p>
</div>
<div class="paragraph">
<p>In the above Example, Once Line 4 has finished, Line 5 and Line 6 when they execute they run on a thread linked to asp.net context. The below stack is what you would see when Thread.Sleep is called (Line 4)</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/async2.png" alt="async2.png">
</div>
</div>
<div class="paragraph">
<p>Now, Let’s try to change the code to use ConfigureAwait(false)</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/async3.png" alt="async3.png">
</div>
</div>
<div class="paragraph">
<p>Now, what happens is the Line5 and Line6 will run on Thread Pool thread which is not LINKED to aspnet context. Here is the stack for the same which shows it doesn’t have any aspnet context linked.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/async4.png" alt="async4.png">
</div>
</div>
<div class="paragraph">
<p>Why do you need ConfigureAwait()</p>
</div>
<div class="paragraph">
<p>If you read this blog <a href="http://blog.stephencleary.com/2012/02/async-and-await.html" class="bare">http://blog.stephencleary.com/2012/02/async-and-await.html</a> you can see this sample.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/async5.png" alt="async5.png">
</div>
</div>
<div class="paragraph">
<p>Here is what happens on Button1_Click</p>
</div>
<div class="paragraph">
<p>-Line 1 Will execute</p>
</div>
<div class="paragraph">
<p>-call getEmployeeDetailsAsync</p>
</div>
<div class="paragraph">
<p>-Line 4 will Execute and because it has an await and “awaitable operation”  is still running, the control is passed back to Button1_Click</p>
</div>
<div class="paragraph">
<p>-Line 2 will Execute and since there is a Wait, this will be in hung state and this is what the stack looks like.</p>
</div>
<div class="paragraph">
<p>-Line 3 can only Execute if Line 4 can finish.</p>
</div>
<div class="paragraph">
<p>-Now once the Line 4 (awaitable operation) has finished, Line 5 will execute synchronously.</p>
</div>
<div class="paragraph">
<p>-The problem is Line5, to execute that line it needs aspnet context and that context is already linked to below thread which is owned while executing Line 2 and this will lead to deadlock.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/async6.png" alt="async6.png">
</div>
</div>
<div class="paragraph">
<p>To fix this issues you need to use ConfigureAwait(False)  which will make Line 5 and any other code below “await” to run without using the httpContext.</p>
</div>]]></description><link>https://fasigpt.github.io/2017/06/16/Asynchronous-Programming-async-await-Configure-Await-deadlock.html</link><guid isPermaLink="true">https://fasigpt.github.io/2017/06/16/Asynchronous-Programming-async-await-Configure-Await-deadlock.html</guid><category><![CDATA[asp.net]]></category><category><![CDATA[asynchronous programming]]></category><pubDate>Fri, 16 Jun 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[IP Addresses in Azure Virtual Machines[IAAS]]]></title><description><![CDATA[<div class="paragraph">
<p>IP Addresses in Azure:</p>
</div>
<div class="paragraph">
<p>In the classic portal or when you do the classic deployment we have the commands “Set-AzureReservedIPAssociation” and “Set-AzurePublicIP” to create Public Reserved IP and Instance Level Public IP respectively.</p>
</div>
<div class="paragraph">
<p>You can read the below blogs to understand the difference
<a href="https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-instance-level-public-ip" class="bare">https://docs.microsoft.com/en-us/azure/virtual-network/virtual-networks-instance-level-public-ip</a>
<a href="https://blogs.technet.microsoft.com/canitpro/2014/10/28/step-by-step-assign-a-public-ip-to-a-vm-in-azure/" class="bare">https://blogs.technet.microsoft.com/canitpro/2014/10/28/step-by-step-assign-a-public-ip-to-a-vm-in-azure/</a></p>
</div>
<div class="paragraph">
<p>Now, there may be a slight difference how these IPs behave when you deploy a VM using the new deployment model which is the “Resource Manager” type. The above commands wouldn’t work for the new deployment Model.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/ip1.png" alt="ip1.png">
</div>
</div>
<div class="paragraph">
<p>Assigning Dynamic Public IP to VM: (using Portal)</p>
</div>
<div class="paragraph">
<p>When you deploy a VM to one of your Virtual Network, you can configure the Public IP during this time.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/ip2.png" alt="ip2.png">
</div>
</div>
<div class="paragraph">
<p>The IP is dynamic which means it might change when you reboot the server</p>
</div>
<div class="paragraph">
<p>Assigning Static Public IP to VM: (using Powershell)</p>
</div>
<div class="paragraph">
<p>You can list all the IP Addresses allotted to your resource group name using Get-AzureRmPublicAddress. In the below picture we can see there is one dynamic IP</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/ip3.png" alt="ip3.png">
</div>
</div>
<div class="paragraph">
<p>Now, let’s try to get one Static Public IP using PowerShell. Here are the command for the same.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/ip4.png" alt="ip4.png">
</div>
</div>
<div class="paragraph">
<p>Now lets run the Get-AzureRmPublicAddress again and now we can see another IP in this resource group and this is Static.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/ip5.png" alt="ip5.png">
</div>
</div>
<div class="paragraph">
<p>You can bind this to a VM from Azure Portal or through powershell Set-AzureRmPublicIpAddress</p>
</div>
<div class="paragraph">
<p>**Now the difference between these IPs are, the static IP will be reserved even after the machine is re started”</p>
</div>
<div class="paragraph">
<p>Assigning Static/Reserved IP to Cloud Service:</p>
</div>
<div class="paragraph">
<p>You cannot assign static IP to web role or Worker role instances but you can assign it to the cloud service only.</p>
</div>
<div class="paragraph">
<p>Here I am creating a reserved IP and assigning it to my cloud service</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/ip6.png" alt="ip6.png">
</div>
</div>
<div class="paragraph">
<p>And now you can assign using</p>
</div>
<div class="paragraph">
<p>Set-AzureReservedIPAssociation -ReservedIPName reservedIpForCloudService  -ServiceName  “yourservice”  (you can run get-AzureService to get the servicename)</p>
</div>]]></description><link>https://fasigpt.github.io/2017/06/06/IP-Addresses-in-Azure.html</link><guid isPermaLink="true">https://fasigpt.github.io/2017/06/06/IP-Addresses-in-Azure.html</guid><category><![CDATA[azure azure-networking]]></category><pubDate>Tue, 06 Jun 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Implementing Authentication in an ASP.NET Core application using Azure Active Directory]]></title><description><![CDATA[<div class="paragraph">
<p>Implementing Authentication in an ASP.NET Core application using Azure Active Directory.</p>
</div>
<div class="paragraph">
<p>In an on premise world, there are different ways of implementing Authentication and here are some of the scenarios</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In an Windows world typically you host your site on a WebServer like IIS and you enable Windows Authentication schemes like Kerberos or NTLM for an in house applications (intranet sites). The Windows Subsystem (LSAS) talks to the on premise Active Directory (Domain Controllers) to implement these Authentication Protocols.</p>
</li>
<li>
<p>The above mechanism requires users to be present in the Active Directory but if you need to sign in with your own custom users then the other approach is to use asp.net membership provider which provides facility to create new users and store them in Database like SQL. So, now any non-domain user can use the site and services.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Imagine you access ten different public sites and you have ten different usernames and passwords to remember. It’s a tedious Job to remember all different usernames and passwords. If you happen to use same password across all sites and if the password gets hacked then you are in trouble!</p>
</div>
<div class="paragraph">
<p>Today Social Login is a buzzword which is completely different than our traditional authentication process. This approach integrates applications with third party providers like Facebook ,Twitter ,Google to provide the Single Sign on Experience.</p>
</div>
<div class="paragraph">
<p>The Azure Active Directory [AAD] provides different Services and one of them is the Identity Management. The AAD provides both options of authenticating an user against domain user and also can help you to easily integrate your application with social login providers (facebook,gmail etc)</p>
</div>
<div class="paragraph">
<p>To begin with, you need to create an Azure Active Directory B2C ( Business to Consumer) Connect which is basically the Cloud Service which implements OpenID Connect authentication protocol on top of OAuth 2.0.  In this Example we will use Visual Studio 2017 to quickly create an asp.net core application and enable Azure Active Directory Based Authentication</p>
</div>
<div class="paragraph">
<p>Step 1 :
Create the Active Directory b2c Connect using the steps outlined here <a href="https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-get-started" class="bare">https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-get-started</a></p>
</div>
<div class="paragraph">
<p>Step2:</p>
</div>
<div class="paragraph">
<p>Create an asp.net core project targeting .net Framework</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/auth1.png" alt="auth1.png">
</div>
</div>
<div class="paragraph">
<p>Now, Select Web Application and Click on Change Authentication</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/auth2.png" alt="auth2.png">
</div>
</div>
<div class="paragraph">
<p>Now, Select Work or School Accounts. (Make sure you are using the same account used for azure portal to login to Visual Studio). You will see the b2c tenant listed here (in the Domain Text box) that you created in the step1. Now press OK</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/auth3.png" alt="auth3.png">
</div>
</div>
<div class="paragraph">
<p>Here are some of the things that happens to your MVC project behind the scenes</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>It adds references to Couple of Nuget Packages “Microsoft.AspnetCore.Authentication.Cookies” and “Microsoft.AspnetCore.Authentication.OpenIdConnect”</p>
</li>
<li>
<p>The ConfigureServices and Configure method inside Startup.cs are updated to inject the Middleware to perform openId Authentication</p>
</li>
</ol>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/auth4.png" alt="auth4.png">
</div>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/auth5.png" alt="auth5.png">
</div>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The above method reads some of the settings like ClientID, TenantId which are also updated in the appsettings.Json file</p>
</li>
</ol>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/auth6.png" alt="auth6.png">
</div>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>The ClientID is the unique ID generated for each of the application that you register under that tenant. You can also manually create the ClientID by going to the azure portal and selecting the application settings for that tenant.</p>
</li>
<li>
<p>The HomeController is decorated with Authorize attribute that will force the user to perform Authentication</p>
</li>
</ol>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/auth7.png" alt="auth7.png">
</div>
</div>
<div class="paragraph">
<p>Now to test the authentication you should create an user on the azure portal for that specific tenant that you created. Here is the snapshot of that flow</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/auth8.png" alt="auth8.png">
</div>
</div>
<div class="paragraph">
<p>Now go ahead and launch the default site of your site and it should take you to the login page on which you can enter the newly created user and password. Once the user is authenticated you should see the Home/Index page loading with the username listed.</p>
</div>]]></description><link>https://fasigpt.github.io/2017/05/31/Implementing-Authentication-in-an-ASPNET-Core-application-using-Azure-Active-Directory.html</link><guid isPermaLink="true">https://fasigpt.github.io/2017/05/31/Implementing-Authentication-in-an-ASPNET-Core-application-using-Azure-Active-Directory.html</guid><category><![CDATA[asp.net]]></category><pubDate>Wed, 31 May 2017 00:00:00 GMT</pubDate></item><item><title><![CDATA[Introduction to .Net Libaries and Runtime BaseClassLibrary-vs-CLR-CoreFx-vs-CoreClr]]></title><description><![CDATA[<div class="paragraph">
<p>Base Class Library v/s CLR:</p>
</div>
<div class="paragraph">
<p>The .Net Framework Base Class Library is the base foundation for developing applications, components and Controls as it exposes Several APIS implemented in different namespaces like System.IO, System.Globalization and many more.
Under the hood, the actual component that has been refereed to Base Class Library is called MSCORLIb.dll. The actual source has been made open source and is available here <a href="https://referencesource.microsoft.com/#mscorlib,namespaces" class="bare">https://referencesource.microsoft.com/#mscorlib,namespaces</a>.</p>
</div>
<div class="paragraph">
<p>To understand this a bit more, let’s see what happens when I create a file from my asp.net web page using the below code.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/bcl1.png" alt="bcl1.png">
</div>
</div>
<div class="paragraph">
<p>I attached a debugger to see how File Creation happens from my Page_Load function, and in the below stack we can see it ultimately calls a File Create API which is in MSCORLIB and which in turn would make a native call to OS through kernel32!CreateFile API.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/bcl2.png" alt="bcl2.png">
</div>
</div>
<div class="paragraph">
<p>CLR : Common Language Runtime:</p>
</div>
<div class="paragraph">
<p>Your application code/base class library calls all run on an environment called CLR. The .net framework by default sits in the folder C:\Windows\Microsoft.NET\Framework64\v4.0.30319 and it has a dll called clr.dll which can be seen below</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/bcl3.png" alt="bcl3.png">
</div>
</div>
<div class="paragraph">
<p>The clr.dll is the runtime library and implements most functionality including Garbage Collection, Memory Management, Thread management.</p>
</div>
<div class="paragraph">
<p>Now, let’s look at same of the stacks in action when CLR runtime is handling the above functionalities.</p>
</div>
<div class="paragraph">
<p>Thread Management: The previous stack that you saw wasn’t complete, but here you can see at the bottom of stack how CLR runtime handles the thread required to execute your code.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/bcl4.png" alt="bcl4.png">
</div>
</div>
<div class="paragraph">
<p>Garbage Collection: In the below thread the system.xml needed more space and that allocation was handled through CLR.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/bcl5.png" alt="bcl5.png">
</div>
</div>
<div class="paragraph">
<p>CoreFx vs CoreClr:</p>
</div>
<div class="paragraph">
<p>Base Class Library is for applications targeting full .Net Framework but for asp.net core applications the base class library is called coreFx and in this image we can see how they fit to each framework.</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/bcl6.png" alt="bcl6.png">
</div>
</div>
<div class="paragraph">
<p>The CoreFx is fully open Source and is available on GitHub <a href="https://github.com/dotnet/corefx" class="bare">https://github.com/dotnet/corefx</a></p>
</div>
<div class="paragraph">
<p>When you install .net core , all different versions sit in a default location C:\Program Files\dotnet\shared\Microsoft.NETCore.App</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/bcl7.png" alt="bcl7.png">
</div>
</div>
<div class="paragraph">
<p>In the below picture you can see the CoreFx libraries (System.Collections. System.IO etc)</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/bcl8.png" alt="bcl8.png">
</div>
</div>
<div class="paragraph">
<p>And here is the CoreClr dll which implements multiple functionalities including GC</p>
</div>
<div class="imageblock">
<div class="content">
<img src="https://fasigpt.github.io/images/bcl9.png" alt="bcl9.png">
</div>
</div>]]></description><link>https://fasigpt.github.io/2017/05/31/Base-Class-Library-vs-CLR-Core-Fx-vs-Core-Clr.html</link><guid isPermaLink="true">https://fasigpt.github.io/2017/05/31/Base-Class-Library-vs-CLR-Core-Fx-vs-Core-Clr.html</guid><category><![CDATA[asp.net]]></category><pubDate>Wed, 31 May 2017 00:00:00 GMT</pubDate></item></channel></rss>