<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: gopkumr</title>
    <description>The latest articles on DEV Community by gopkumr (@gopkumr).</description>
    <link>https://dev.to/gopkumr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F96649%2Fedd066bd-8201-4965-aed0-35d1ea55be08.jpg</url>
      <title>DEV Community: gopkumr</title>
      <link>https://dev.to/gopkumr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gopkumr"/>
    <language>en</language>
    <item>
      <title>Move azure resources between resource groups</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Tue, 12 Oct 2021 06:20:59 +0000</pubDate>
      <link>https://dev.to/gopkumr/move-azure-resources-between-resource-groups-1bh6</link>
      <guid>https://dev.to/gopkumr/move-azure-resources-between-resource-groups-1bh6</guid>
      <description>&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;While working with Azure cloud platform, often there will be instances where resources needs moving across resource groups for maintenance reasons or because of re-organizing of products. There might even cases where the resource may need to be moved across subscriptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;In Azure resources can be moved across resource groups from the portal UI or Azure CLI or powershell or from the rest APIs. Moving the resource using the portal UI is as easy as going through a wizard like steps and clicking finish at the end of it. The process also validates if the resource can be moved or not, for example an Azure SQL Database cannot be moved without moving the SQL Server instance, and when a SQL Server instance is moved across, all the databases gets moved automatically.&lt;/p&gt;

&lt;p&gt;From the UI, there are three ways of getting to the wizard.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Azure Resource Mover service&lt;/li&gt;
&lt;li&gt;Move option at the top of the Resource Group Screen&lt;/li&gt;
&lt;li&gt;Move option at the top of the Resource Screen.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All the above options lead to the same wizard screen when you can choose the destination subscription and resource group and initiate the move. This will validate if the resource support moving as well as if all the criteria is satisfied for the resource to be moved.&lt;/p&gt;

&lt;p&gt;You can find all the information regarding what resources currently support moving &lt;a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/move-support-resources"&gt;here&lt;/a&gt;. Also the criteria that any resource that supports moving needs to satisfy to be able to move can be found &lt;a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/move-limitations/app-service-move-limitations"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The move does not copy over the role assignments to the destination resource, so all the role assignments will have to redone after the move is completed. There is no downtime to the usage of the resource, but the resource will be locked for few hours to any changes even though the move is completed in lesser time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Powershell&lt;/strong&gt; command &lt;a href="https://docs.microsoft.com/en-us/powershell/module/az.resources/move-azresource?view=azps-6.4.0"&gt;Move-AzResource&lt;/a&gt; can be used to execute the move from Powershell&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Azure CLI&lt;/strong&gt; command &lt;a href="https://docs.microsoft.com/en-us/cli/azure/resource?view=azure-cli-latest#az_resource_move"&gt;az resource move&lt;/a&gt; can be used to execute move from any CLI that has Azure CLI installed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rest Endpoint&lt;/strong&gt;  POST &lt;a href="https://management.azure.com/subscriptions/%7Bsource-subscription-id%7D/resourcegroups/%7Bsource-resource-group-name%7D/moveResources?api-version=%7Bapi-version%7D"&gt;https://management.azure.com/subscriptions/{source-subscription-id}/resourcegroups/{source-resource-group-name}/moveResources?api-version={api-version}&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://docs.microsoft.com/en-us/rest/api/resources/resources/move-resources"&gt;Details Here&lt;/a&gt; can be used to trigger the source move passing the payload with resources ids and the target resource group names.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"resources"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;resource-id-1&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;resource-id-2&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"targetResourceGroup"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/subscriptions/&amp;lt;subscription-id&amp;gt;/resourceGroups/&amp;lt;target-group&amp;gt;"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Azure resource mover also bring in the capability of moving the resources across regions more about it can be found &lt;a href="https://docs.microsoft.com/en-us/azure/resource-mover/move-region-within-resource-group"&gt;here&lt;/a&gt; &lt;/p&gt;

</description>
      <category>microsoftazure</category>
      <category>azure</category>
    </item>
    <item>
      <title>Cloud Resume Challenge - Azure Serverless</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Sun, 27 Jun 2021 23:18:48 +0000</pubDate>
      <link>https://dev.to/gopkumr/cloud-resume-challenge-azure-serverless-1b4c</link>
      <guid>https://dev.to/gopkumr/cloud-resume-challenge-azure-serverless-1b4c</guid>
      <description>&lt;p&gt;I recently came across the site &lt;a href="https://cloudresumechallenge.dev/"&gt;https://cloudresumechallenge.dev/&lt;/a&gt; and decided to give it a try using Azure services. To start simple I decided to ignore the DB, CDN part etc and just have the the UI and the middler layer of the app. Below is the high level architecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--acgZLksS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xnkyaplofd84u49nsshv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--acgZLksS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xnkyaplofd84u49nsshv.png" alt="Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The front end of the app will be hosted a static web site in Azure Blob storage. Backend will be an Azure function that will feed the resume data to the frontend over HTTP, the azure function will be a HTTP triggered function. &lt;br&gt;
Currently the resume data in JSON format hardcoded in the Azure Function code. As an upgrade to the app, the JSON data can be moved to a CosmosDB instance and put an Azure CDN in front of the UI to deliver content fast to users.&lt;/p&gt;
&lt;h2&gt;
  
  
  Development Environment
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Frontend&lt;/strong&gt;: Blazor WebAssembly&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backend&lt;/strong&gt;: Azure Function using C# (Function Auth)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IDE&lt;/strong&gt;: VS Code&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IAC&lt;/strong&gt;: Azure ARM Template&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source Control&lt;/strong&gt;: Github&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CI/CD&lt;/strong&gt;: Github Actions&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  The App project
&lt;/h2&gt;

&lt;p&gt;The project is divided into 3 parts.&lt;br&gt;&lt;br&gt;
&lt;strong&gt;Core&lt;/strong&gt;: A dotnet standard 2.0 library project that contains all the entities used in the application. It also contains the interfaces and implementation of services, the classes that contains all the logic to get the data ready for the caller.&lt;br&gt;
Created using&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;dotnet new classlib --framework netstandard2.0&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The one service class that currently resides in the core project is the ResumeService, which calls the Function backend and deserialized the JSON to its class instance and return. This service is injected in the frontend to complete the rendering the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Frontend&lt;/strong&gt;: Blazor WebAssemly project, which contains all the UI rendering logic. The projects refers to the Core project to get the resume data.&lt;br&gt;
Created using&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;dotnet new blazorwasm --framework net5.0&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;For now the function will respond to HTTP calls with a JSON representing the resume data. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Backend&lt;/strong&gt;: Azure Function project&lt;br&gt;
Created using&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;func init backend --dotnet  &lt;br&gt;
func new --name backend --template "HTTP trigger" --authlevel "function"&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Infrastructure as code (IAC)
&lt;/h2&gt;

&lt;p&gt;The infrastructure for deploying the application is coded using Azure Resource manager template for repeatable deployment, this makes it east to setup an azure environment quickly and without human errors. Also the infrastructure can be version controlled reviewed and provisioned as part of the CI/CD pipeline. &lt;/p&gt;

&lt;p&gt;referred the Azure ARM template quick start github &lt;a href="https://github.com/Azure/AzureStack-QuickStart-Templates"&gt;here&lt;/a&gt; to get started with the azure services.&lt;/p&gt;

&lt;p&gt;The ARM template has the Azure Static website and Azure Function configured.&lt;/p&gt;

&lt;h2&gt;
  
  
  CI/D
&lt;/h2&gt;

&lt;p&gt;There are two github actions workflow, one is to deploy the infrastructure and another to deploy the code. The infrastructure is deployed manually as we don't want to spin up new infrastructure element automatically on any event. The&lt;br&gt;
source code gets deployed on any commit on the &lt;em&gt;master&lt;/em&gt; branch in the github repository.&lt;/p&gt;
&lt;h3&gt;
  
  
  Deploying Infrastructure
&lt;/h3&gt;

&lt;p&gt;To execute the workflow on Azure, we need to register github actions as an Azure AD and use the client credentials authentication flow to get access to create resources. Also, while creating a service principle for github actions, give permission on to one resource group to have maximum restrictions on. &lt;/p&gt;

&lt;p&gt;use the below command to create an Azure service principle and copy the returned JSON into Github secrets of your repo and call it AZURE_CREDENTIALS. substitute the subscription id, resource group name and the app name.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;az ad sp create-for-rbac --name ResumeAppGithub --role contributor --scopes /subscriptions/{subscriptionId}/resourceGroups/{MyResourceGroup} --sdk-auth&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;In the YAML file to deploy the ARM template we use the &lt;em&gt;azure/arm-deploy@v1&lt;/em&gt; which taken in subscriptionid and resourcegroupname as input, so store those too in the repo secret so that you don't have to expose the values into the code.&lt;/p&gt;

&lt;p&gt;You can check the ARM template &lt;a href="https://github.com/gopkumr/Serverless-Resume/blob/28f4704aa0fd55ddd2c14395d2f5d73a2a1e134b/infra/resumeapp-infra.json"&gt;here&lt;/a&gt; and the YAML file to deploy it &lt;a href="https://github.com/gopkumr/Serverless-Resume/blob/28f4704aa0fd55ddd2c14395d2f5d73a2a1e134b/.github/workflows/infra.yml"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploying the backend azure function
&lt;/h3&gt;

&lt;p&gt;Deploying the function app is easy as the github action can already login to Azure as an app. So all we are have to do is publish the app and upload it to the function service using the &lt;em&gt;Azure/functions-action@v1&lt;/em&gt; action.&lt;/p&gt;

&lt;p&gt;You can check the yaml file &lt;a href="https://github.com/gopkumr/Serverless-Resume/blob/2edc1f129863a8c4f2b77fe350fe801f3d0f41ca/.github/workflows/function.yml"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Deploying the frontend static web app
&lt;/h3&gt;

&lt;p&gt;Deploying Blazor project follows two steps, one is to publish the project and next is to upload all the published files to the static web app. Both these tasks can be done by using the &lt;em&gt;Azure/static-web-apps-deploy@v1&lt;/em&gt; action, which uses microsoft/oryx to build the Blazor project and copy over the content to the azure static app website.&lt;/p&gt;

&lt;p&gt;You can check te yaml file &lt;a href="https://github.com/gopkumr/Serverless-Resume/blob/3a3fb515c5c1666cae89246c2b12c5a088e051cb/.github/workflows/staticwebapp.yml"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The app currently implements just an azure function that returns a hardcoded JSON data that represents the resume and a Blazor app thats deployed on azure static web app to render the resume. &lt;br&gt;
The next revision of the app would be to add a Azure CDN service to cache the resume UI and also to return the content faster to whoever accesses it from where ever in the world. Azure function returns a hard coded JSON string which needs a change and have the resume stored as a document in the document in cosmos DB.&lt;/p&gt;

&lt;p&gt;The full source code, IAC templates and the actions YAML files can be found in the &lt;a href="https://github.com/gopkumr/Serverless-Resume"&gt;github repository&lt;/a&gt;&lt;/p&gt;

</description>
      <category>azurestaticwebapp</category>
      <category>serverless</category>
      <category>azure</category>
      <category>azurefunctions</category>
    </item>
    <item>
      <title>Implementing custom feature flags - Azure App Configuration</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Mon, 21 Jun 2021 23:18:48 +0000</pubDate>
      <link>https://dev.to/gopkumr/implementing-custom-feature-flags-azure-app-configuration-42jk</link>
      <guid>https://dev.to/gopkumr/implementing-custom-feature-flags-azure-app-configuration-42jk</guid>
      <description>&lt;p&gt;This is a continuation from the &lt;a href="https://dev.to/gopkumr/implementing-feature-flags-using-azure-27n2"&gt;previous article&lt;/a&gt; on feature flags implemented using Azure App configuration service to maintain the flags. Just to reiterate, feature management can be implemented using config files but this article is trying to implement feature flags connecting to Azure App configuration service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://dev.to/gopkumr/implementing-feature-flags-using-azure-27n2"&gt;previous article&lt;/a&gt; described about implementing a boolean feature flag to turn on/off a feature. In this article I am trying to implement a custom feature flag. Microsoft provides few predefined custom feature flags or feature filters (as they are called) Targeting, TimeWindow, and Percentage (more about it &lt;a href="https://docs.microsoft.com/en-us/azure/azure-app-configuration/howto-feature-filters-aspnet-core" rel="noopener noreferrer"&gt;here&lt;/a&gt;), which covers most usecases, however, there might be situations where you find the predefined ones falling short. In this article I am building a filter ground up with a made up custom logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Updates
&lt;/h2&gt;

&lt;p&gt;Create a customer filter is as simple as creating a class and implementing the &lt;code&gt;Microsoft.FeatureManagement.IFeatureFilter&lt;/code&gt;, override the &lt;code&gt;EvaluateAsync&lt;/code&gt; method add the logic to decide if feature should be enabled. Thats it! What i want to show is how do we wire up this class into the application flow and configure the flag in  Azure app configurations.&lt;/p&gt;

&lt;p&gt;Below is our feature filter class and some supporting class for logic implementation&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;

&lt;span class="c1"&gt;//The feature filter will be known my this name in the configuration.&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;FilterAlias&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ShortTimeFeature"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SecondsFeatureFilter&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Microsoft&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FeatureManagement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IFeatureFilter&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;IMinuteFeaturePropertyAccessor&lt;/span&gt; &lt;span class="n"&gt;minuteFeatureContextAccessor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="c1"&gt;//The IMinuteFeaturePropertyAccessor is an implementation that I have used to capture first load &lt;/span&gt;
        &lt;span class="c1"&gt;// time of the application. The IMinuteFeaturePropertyAccessor is loaded as a singleton in DI.&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;SecondsFeatureFilter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IMinuteFeaturePropertyAccessor&lt;/span&gt; &lt;span class="n"&gt;minuteFeatureContextAccessor&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;minuteFeatureContextAccessor&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;minuteFeatureContextAccessor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;EvaluateAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;FeatureFilterEvaluationContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;//The logic is to disable the feature after configured seconds the user has used the application&lt;/span&gt;
            &lt;span class="c1"&gt;//The seconds is configured as parameter in the feature flag.&lt;/span&gt;
            &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;EnabledSeconds&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parameters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetSection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"EnabledSeconds"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Subtract&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;minuteFeatureContextAccessor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetStartTime&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="n"&gt;TotalSeconds&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;EnabledSeconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromResult&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MinuteFeturePropertyAccessor&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;IMinuteFeaturePropertyAccessor&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;DateTime&lt;/span&gt; &lt;span class="n"&gt;startTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;MinuteFeturePropertyAccessor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;startTime&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;DateTime&lt;/span&gt; &lt;span class="nf"&gt;GetStartTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;startTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;IMinuteFeaturePropertyAccessor&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;DateTime&lt;/span&gt; &lt;span class="nf"&gt;GetStartTime&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Once the feature filter is create, it needs to be added into the feature management middleware. The middleware will make sure that the filter class is invoked when the flag check is triggers in the application flow (navigation link, action filter, filtermanager check). &lt;/p&gt;

&lt;p&gt;Below the configure service method, where the feature filter is added as well as the supporting classes in my sample.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;

 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ConfigureServices&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IServiceCollection&lt;/span&gt; &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddSession&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddHttpContextAccessor&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddControllersWithViews&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddSingleton&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IMinuteFeaturePropertyAccessor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;MinuteFeturePropertyAccessor&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
            &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddFeatureManagement&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;AddFeatureFilter&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;SecondsFeatureFilter&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
            &lt;span class="n"&gt;services&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAzureAppConfiguration&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The ways feature flag can be used in the app is exactly same  as described in the previous article. The feature flag is going to called &lt;em&gt;TimeLimit&lt;/em&gt;. example code is as below&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;

 &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;FeatureGate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"TimeLimit"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IActionResult&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;Index&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;View&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Rest of the startup and program class will be same as the &lt;a href="https://dev.to/gopkumr/implementing-feature-flags-using-azure-27n2"&gt;previous article&lt;/a&gt;, which basically implements Azure app configuration integration.&lt;/p&gt;

&lt;p&gt;To create the configuration entry in Azure, we use the feature explorer in Azure App configuration service. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a feature flag, enter a feature name same as what was used in the code &lt;em&gt;TimeLimit&lt;/em&gt; and check &lt;em&gt;Use feature filter&lt;/em&gt; and select &lt;em&gt;Custom&lt;/em&gt;. &lt;/li&gt;
&lt;li&gt;In the custom feature filter name, enter the FeatureFilter name as given in the FeatureFilter alias attribute &lt;em&gt;ShortTimeFeature&lt;/em&gt;.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmsf8pykmw5k9o4wopwdy.png" alt="Add feature flag"&gt;
&lt;/li&gt;
&lt;li&gt;Click the three dots and edit parameters and enter the parameter name and value used in the feature filter implementation &lt;em&gt;EnabledSeconds&lt;/em&gt; and 60
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flij900eg19t5ejdtvk9q.png" alt="Enable feature filter"&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkxexgvgei8uze433ierq.png" alt="Add parameters "&gt;
Also, remember to have the Azure App Configuration connection string to be added/updated in the config filer of the application and make sure that the feature flag is enabled in the feature explorer.Now we have wired up the feature flag and dependent configurations and the app is ready to executed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This code now will make your feature enabled for 60secs after the user has opened the application. Post 60secs the feature will get disabled, like short preview of a beta code. As mentioned earlier this is just to demonstrate how easy it is to implement a custom feature flag and control features based on different business needs.&lt;/p&gt;

</description>
      <category>dotnetcore</category>
      <category>csharp</category>
      <category>azure</category>
      <category>featureflags</category>
    </item>
    <item>
      <title>Implementing feature flags - Azure App Configuration</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Sat, 15 May 2021 23:00:48 +0000</pubDate>
      <link>https://dev.to/gopkumr/implementing-feature-flags-using-azure-27n2</link>
      <guid>https://dev.to/gopkumr/implementing-feature-flags-using-azure-27n2</guid>
      <description>&lt;p&gt;Feature flag is a very popular practice in modern application development, which is used to specifically hide features implemented that are not yet ready to be used by wider audience, and when ready can be enabled by a flip of a switch. The flags can also be used as a kill switch for application feature when it not working as expected.&lt;/p&gt;

&lt;p&gt;With feature flags implemented, it would be effective to have the features enabled or disabled from a location outside of the application infrastructure or configuration, this way we can have features spanning across applications be controlled via a centralized flag. Azure has feature management as part of the Azure App configuration service which can manage feature flags and maintain it separate from your hosting model and will act as a centralized repository for feature flags. Microsoft also provides libraries for different programing languages to consume Azure App Configuration service. More about it can be &lt;a href="https://docs.microsoft.com/en-us/azure/azure-app-configuration/manage-feature-flags"&gt;found here&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Azure App Configuration
&lt;/h2&gt;

&lt;p&gt;To start with, create the App Configuration service in Azure. For trying out the service, I will use the free tier.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y9N25QRZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/createappconfigazure.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y9N25QRZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/createappconfigazure.png" alt="Create service"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the service is created, In the left panel, under operations section, we can navigate to the Feature Manager screen and create a flag. The flag creation is as simple as giving a name to it. The screen also gives an option to create the flag as a FeatureFilter, which is used when the flag is not just a boolean value and you want to control the flag based on other criteria like a subset of users or switching a flag on/off for a time frame. We will keep the details on FeatureFilter for another post.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WXKTwnDq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featueflagcreationazure.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WXKTwnDq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featueflagcreationazure.png" alt="Create flag"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the flag is created, it can be toggled from the feature manager screen.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6rAYff9o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featuremanagerazure.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6rAYff9o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featuremanagerazure.png" alt="Modify flag"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note the connection string to the Azure AppConfiguration service, which we will use in our app to connect.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Kk5YhUGA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/connectionstring.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Kk5YhUGA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/connectionstring.png" alt="Connection string"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Consuming Azure App Configuration in a WebApp
&lt;/h2&gt;

&lt;p&gt;I am implementing a simple web application using ASP.Net Core MVC default app to consume the app configuration service. Adding a view and a controller for the new feature called Feature1. The feature for now will only have a single index page which displays the feature name. Add the feature link to the navigation menu too. While the Microsoft FeatureManagement libraries in aspnetcore can work with flags stored in application's local config files or a database, here I am trying to have it work with the azure app configuration service.&lt;/p&gt;

&lt;p&gt;To consume azure app configuration service we need add the below nuget package&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Microsoft.Azure.AppConfiguration.AspNetCore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;aspnetcore feature management requires the below nuget pacakge&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Microsoft.FeatureManagement.AspNetCore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the Azure App Configuration connection string to the &lt;code&gt;appsettings.json&lt;/code&gt; connection strings section with a key, I will use  &lt;code&gt;AppConfiguration&lt;/code&gt; .&lt;br&gt;&lt;br&gt;
To add the App Configuration from azure into the application, update the program.cs file &lt;code&gt;CreateWebHostBuilder&lt;/code&gt; configuration. Within the configurewebhostdefaults method, add code to configure custom configuration source using &lt;code&gt;ConfigureAppConfiguration&lt;/code&gt; method.&lt;br&gt;&lt;br&gt;
Within the method, retrieve the azure app configuration connection string from the &lt;code&gt;appsettings.json&lt;/code&gt; and add the azure app configuration as a configuration source using &lt;code&gt;AddAzureAppConfiguration&lt;/code&gt; method, also enable Feature flags.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IuDGb2kv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/programcs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IuDGb2kv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/programcs.png" alt="Program.cs changes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add the feature management to the dependency container using &lt;code&gt;AddFeatureManagement&lt;/code&gt; in the configureservices method in startup.cs.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CH5TsPZw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/startupcs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CH5TsPZw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/startupcs.png" alt="Startup.cs changes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the setup is done there are few ways the feature flags can be used in the application code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Action filter
&lt;/h3&gt;

&lt;p&gt;An action filter &lt;code&gt;FeatureGate("&amp;lt;feature name&amp;gt;")&lt;/code&gt; can be used to prevent the action from getting triggered if the feature name passed to the filter is not enabled in the Azure App Configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GfqGgv3R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featuregate.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GfqGgv3R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featuregate.png" alt="Action Filter usage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature Manager Service
&lt;/h3&gt;

&lt;p&gt;If the requirement is to stop execution of a logic based on the feature flag, then a service of type &lt;code&gt;IFeatureManager&lt;/code&gt; can be injected in the controller and methods like &lt;code&gt;IFeatureManager.IsEnabledAsync("&amp;lt;feature name&amp;gt;")&lt;/code&gt; can be used to check if the feature is enabled.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gA5NDjRM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featureservice.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gA5NDjRM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featureservice.png" alt="Feature manager service usage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Navigation Links
&lt;/h3&gt;

&lt;p&gt;By adding tag helpers from &lt;code&gt;@addTagHelper *, Microsoft.FeatureManagement.AspNetCore&lt;/code&gt;  gives the tag &lt;code&gt;&amp;lt;feature name="&amp;lt;feature name&amp;gt;"&amp;gt;&lt;/code&gt; to be used around links or buttons or sections, so that the content of the feature tag is not rendered when the feature specified in the name attribute is not enabled. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CYDmdmXc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featuretag.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CYDmdmXc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/featuretag.png" alt="Html feature tag usage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Doing the above will let you switch on/off the feature in azure and the application will respond to it by removing the link from navigation as well as responding with a HTTP 404 if user tried to access the link directly. With the above implementation,the app needs to be restarted if the flag changes needs to get reflected, as the azure config is loaded only once when the app is launched. To have the config refreshed when it is changed in azure, we need to register a refresh for the azure configuration. Below is how we will do it.&lt;/p&gt;

&lt;p&gt;First, the change to the code&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3mHNc62b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/refreshkey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3mHNc62b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/refreshkey.png" alt="Refresh key usage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here the application monitors the &lt;code&gt;RefreshKey&lt;/code&gt; for any change every 5 seconds (as specified in the cache expiry timespan), when a change in &lt;code&gt;RefreshKey&lt;/code&gt; is noted all azure configurations are refreshed from the service for all keys (specified by refresh all flag).&lt;br&gt;
The refresh key is created as a key-value in the app configuration explorer in azure app configuration.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FhHkHr5I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/createrefreshkey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FhHkHr5I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/createrefreshkey.png" alt="Refresh key usage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the refresh to work, we need to add the AzureAppconfiguration middleware by making the below changes in startup.cs&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4ykFmKjD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/AddAzureAppConfig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4ykFmKjD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/AddAzureAppConfig.png" alt="Add configuration middleware"&gt;&lt;/a&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--grOe18OD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/useazureappconfig.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--grOe18OD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.beneathabstraction.com/blogimages/appconfig/useazureappconfig.png" alt="Refresh configuration middleware"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After this is implemented, you can update your feature flag and modify the feature key, which will cause the app to get the updated feature flags. Advantage of using a refresh key is that, one single key change can trigger refresh of all the feature flags configured. Alternatively, you can register refresh for individual keys which can be set to refresh only those keys that have been updated.&lt;/p&gt;

</description>
      <category>dotnetcore</category>
      <category>csharp</category>
      <category>featureflags</category>
      <category>azure</category>
    </item>
    <item>
      <title>Radio Player using Blazor 5</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Tue, 11 May 2021 06:35:28 +0000</pubDate>
      <link>https://dev.to/gopkumr/radio-player-using-blazor-5-2c2c</link>
      <guid>https://dev.to/gopkumr/radio-player-using-blazor-5-2c2c</guid>
      <description>&lt;p&gt;I have been reading the Blazor 5 documentation and decided to create a simple project to give its features a try. As always, there were a ton of ideas in my mind but while scanning through dev.to i came across a post by &lt;a href="https://dev.to/alekswritescode/radio-player-app-in-react-84k"&gt;Aleks Popovic, where he made a Radio player using react&lt;/a&gt;, so i decided to create one using Blazor 5. I used the same service as Aleks to get the radio stations, called the &lt;a href="https://www.radio-browser.info/"&gt;Radio-Browser&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First step was a to choose a suitable UI which is simple and easy to use as a radio. I borrowed the style of the player from a &lt;a href="https://codepen.io/webandapp/full/reVmyN"&gt;codepen.io sample for music player&lt;/a&gt;. With the UI design out of the way, it was time to create a component and wire up the code to fetch and play radio stations.&lt;/p&gt;

&lt;p&gt;To keep it simple the project currently list a set of predefined genre and fetch stations for a selected genre and display it as a list. The user can choose the station and they listen to it.&lt;/p&gt;

&lt;h2&gt;
  
  
  State persistence
&lt;/h2&gt;

&lt;p&gt;The list of genre is contained within its own component called LeftNavMenu. This component is included within the main layout page which renders the player component. The selected genre is maintained by an in-memory state container. The state container is used by both the LeftNavMenu component and the Player component to share the selected genre. When user selects a different genre from the LeftNavMenu the value in the state container is updated and action is triggered to notify the player component of the change. This approach can be used to share state between nested components or independent components.&lt;/p&gt;

&lt;p&gt;The state container is configured as singleton instance in the service collection dependency container which is injected in all the Blazor components and used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cascade Values and parameters
&lt;/h2&gt;

&lt;p&gt;The index component is the first component that is loaded and it contains the Radio player component. During initialization of the index component the radio server API is triggered to fetch all the radio stations for the selected genre. The fetched radio stations list is passed onto the Radio player component as a parameter, the first station of the list is passed into the  radio player as a cascade value. The difference between the two is that cascading values can be passed onto to all the components within the CascadeValues section, where as for parameters the values would need to be passed to individual components.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Isolation
&lt;/h2&gt;

&lt;p&gt;One issue with CSS is bleeding of style, where style applied in one of the component affecting other components rendered in the same page. This was the issue with the genre LeftNavMenu component. As a was to get around this problem, blazor has introduced CSS isolation where you create a css file along with the component file and name the css file as .razor.css. The component styles are rewritten during compile time by appending a unique identifier to the css properties as well as to the HTML elements in the component UI.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML
&amp;lt;li b-3xxtam6d07&amp;gt;

CSS
li[b-3xxtam6d07]{
    color:red;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All the component styles are then bundled and included inside the www\index.html head tag as .styles.css.&lt;/p&gt;

&lt;p&gt;These were the 3 of the new features that are used in this project and there are more, there are also other features like JS Interop, event handling used within the project which were part of the initial Blazor.&lt;/p&gt;

&lt;p&gt;The source fot the project is available in &lt;a href="https://github.com/vinca-creative/BlazoRadio.git"&gt;github project&lt;/a&gt;, feel free to take a look and give suggestion.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>javascript</category>
      <category>blazor</category>
    </item>
    <item>
      <title>Switch off auto formatting in Visual Studio 2019</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Tue, 16 Feb 2021 21:51:19 +0000</pubDate>
      <link>https://dev.to/gopkumr/switch-off-auto-formatting-in-visual-studio-2019-58go</link>
      <guid>https://dev.to/gopkumr/switch-off-auto-formatting-in-visual-studio-2019-58go</guid>
      <description>&lt;p&gt;If you have landed here searching how to switch off auto formatting of code files in Visual Studio, you are either a code purist who does not like the formatting the IDE is performing or you are like me editing a large auto-generated class file (due to unfortunate situations) and Visual studio hangs or crashes on you every time you do a small change. The good news is there is an option in the IDE to switch feature off.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tools &amp;gt; Options &amp;gt; Basic &amp;gt; Advanced &amp;gt; Editor Help Section &amp;gt; Pretty listing (reformatting)of code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0oek78y9ydu2hdpzl5k3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0oek78y9ydu2hdpzl5k3.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>visualstudio</category>
      <category>visualstudio2019</category>
      <category>microsoftvisualstudio</category>
    </item>
    <item>
      <title>Steps for Deploying a Blazor as Static Site with Docker and Nginx</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Thu, 11 Jun 2020 10:07:44 +0000</pubDate>
      <link>https://dev.to/gopkumr/steps-for-deploying-a-blazor-as-static-site-with-docker-and-nginx-456l</link>
      <guid>https://dev.to/gopkumr/steps-for-deploying-a-blazor-as-static-site-with-docker-and-nginx-456l</guid>
      <description>&lt;h1&gt;
  
  
  Step 1 Publish the Blazor WebAssembly project
&lt;/h1&gt;

&lt;p&gt;Publish the project from Visual Studio,this ensures that the projects is linked which removes all the unwanted dependencies from the output, reducing the size of the assemblies created.&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 2 Create a dockerfile
&lt;/h1&gt;

&lt;p&gt;The docker file is very straightforward, pull the nginx image and copy the published Blazor WebAssembly file from the WWWRoot folder to the html folder in nginx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM nginx:alpine
EXPOSE 80
COPY bin/Release/netcoreapp3.1/publish/wwwroot /usr/share/nginx/html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 3 Build the docker image
&lt;/h1&gt;

&lt;p&gt;use the below command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker build --tag blazorstatic . 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 4 Run the docker container
&lt;/h1&gt;

&lt;p&gt;Run the docker container mapping the port exposed from the container to a port on the host&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; docker run -p 8080:80 blazorstatic   
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Step 5 Access the Blazor WebApp from browser
&lt;/h1&gt;

&lt;p&gt;Access the URL &lt;a href="https://localhost:8080"&gt;https://localhost:8080&lt;/a&gt; which loads the WebApp&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZAkTWxVo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0etothdadxr8h1v5mi6t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZAkTWxVo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/0etothdadxr8h1v5mi6t.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source code for both ASPNet hosting and Static Website Hosting is available in Github: &lt;a href="https://github.com/gopkumr/BlazorTourOfHeroes.git"&gt;https://github.com/gopkumr/BlazorTourOfHeroes.git&lt;/a&gt;&lt;br&gt;
Branch: Perf&lt;/p&gt;

</description>
      <category>blazor</category>
      <category>hosting</category>
      <category>standalone</category>
      <category>nginx</category>
    </item>
    <item>
      <title>Hosting Blazor WebAssembly on ASP.Net Core WebAPI</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Tue, 09 Jun 2020 09:31:24 +0000</pubDate>
      <link>https://dev.to/gopkumr/hosting-blazor-webassembly-on-asp-net-core-5gd5</link>
      <guid>https://dev.to/gopkumr/hosting-blazor-webassembly-on-asp-net-core-5gd5</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;My WebAssembly project has now been configured to be a PWA (refer the previous article in series). It time to introduce hosting. Since the WebAssembly project handles the client side, I want it to be unchanged but be hosted it in a project that can be used as backend for the UI, hence chose WebAPI.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Changes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a new solution and add the already created Blazor WebAssembly project&lt;/li&gt;
&lt;li&gt;Add a new ASPNet core web project and choose WebAPI template and call it the .Server project&lt;/li&gt;
&lt;li&gt;Add reference of the WebAssembly Project to the .Server project.&lt;/li&gt;
&lt;li&gt;Install package Microsoft.AspNetCore.Components.WebAssembly.Server to the .Server project. This package contains the runtime server for Blazor application.&lt;/li&gt;
&lt;li&gt;In the startup class add configuration to the request pipeline to handle Blazor and its routing.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This methods serves the WebAssembly framework files when a request is made to root path. &lt;/span&gt;
&lt;span class="c1"&gt;//This method also take path parameter that can be used if the WebAssembly project is only served &lt;/span&gt;
&lt;span class="c1"&gt;//from part of the project, giving options to combine web assembly project with a web application&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseBlazorFrameworkFiles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;//This configuration helps in serving the static files like &lt;/span&gt;
&lt;span class="c1"&gt;//Javascript and CSS that is part of the Blazor WebAssembly&lt;/span&gt;

 &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseStaticFiles&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="c1"&gt;//Add the below configuration to the end of the UseEndpoint configuration, &lt;/span&gt;
&lt;span class="c1"&gt;//this will serve the index.html file from the WebAssembly when the WebAPI route &lt;/span&gt;
&lt;span class="c1"&gt;//does not find a match in the routing table&lt;/span&gt;

 &lt;span class="n"&gt;endpoints&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MapFallbackToFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"index.html"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your ASPNet Core hosted WebAssembly project is ready to be published and deployed. Pretty easy!&lt;/p&gt;

&lt;p&gt;Next would to move some of the data source maintained in the WebAssembly to the WebAPI Server and use an HTTP call to retrieve it.&lt;/p&gt;

&lt;p&gt;Source Code: &lt;a href="https://github.com/gopkumr/BlazorTourOfHeroes.git"&gt;https://github.com/gopkumr/BlazorTourOfHeroes.git&lt;/a&gt; &lt;br&gt;
Branch: Perf&lt;/p&gt;

</description>
      <category>blazor</category>
      <category>webassembly</category>
      <category>aspnetcore</category>
    </item>
    <item>
      <title>How can I turn my Blazor WebAssembly to PWA?</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Thu, 04 Jun 2020 09:22:54 +0000</pubDate>
      <link>https://dev.to/gopkumr/how-can-i-turn-my-blazor-webassembly-to-pwa-1fao</link>
      <guid>https://dev.to/gopkumr/how-can-i-turn-my-blazor-webassembly-to-pwa-1fao</guid>
      <description>&lt;h2&gt;
  
  
  Lets get started with an existing Blazor WebAssembly project
&lt;/h2&gt;

&lt;p&gt;I already have a Blazor WebAssembly project created implementing Angular Tour of heros application. You can find the project in my GitHub repository here&lt;br&gt;
Repo: &lt;a href="https://github.com/gopkumr/BlazorTourOfHeroes.git"&gt;https://github.com/gopkumr/BlazorTourOfHeroes.git&lt;/a&gt;&lt;br&gt;
Branch: Release&lt;/p&gt;

&lt;h2&gt;
  
  
  Next step is making this into PWA
&lt;/h2&gt;

&lt;p&gt;As with any web application, adding PWA capabilities to Blazor follows the web standard process of adding a manifest json file and the service workers js file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manifest.json file specifies the PWA metadata like name, icon author etc&lt;/li&gt;
&lt;li&gt;Service-Worker.js provides the offline capabilities.
both these files were added to the wwwroot folder and included in the index.html page like below
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link href="manifest.json" rel="manifest" /&amp;gt;
 &amp;lt;script&amp;gt;navigator.serviceWorker.register('service-worker.js');&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have added the files to the project and it can be found in the same GitHub Repo but in a branch called PWA&lt;br&gt;
Repo: &lt;a href="https://github.com/gopkumr/BlazorTourOfHeroes.git"&gt;https://github.com/gopkumr/BlazorTourOfHeroes.git&lt;/a&gt;&lt;br&gt;
Branch: pwa&lt;/p&gt;

&lt;h2&gt;
  
  
  A little about the manifest.json file that i have include in the project
&lt;/h2&gt;

&lt;p&gt;Now that we came to the topic of manifest.json below are the properties I chose to add to my manifest file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;short_name and name: &lt;/strong&gt;
short_name is used on the user's home screen, app launcher, or desktop. name is used when the app is installed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;icons:&lt;/strong&gt;
Set the icons for the browser to use on the home screen, app launcher, desktop etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;start_url: &lt;/strong&gt;
The start_url tells the browser where your application should start when it is launched.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;background_color:&lt;/strong&gt;
The background_color property is used on the splash screen when the application is first launched.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;display:&lt;/strong&gt;
Used to customize what browser UI is shown when your app is launched. Below are the possible values &lt;/li&gt;
&lt;li&gt;
&lt;em&gt;fullscreen:&lt;/em&gt; Opens the web application without any browser UI and takes up the entirety of the available display area.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;standalone:&lt;/em&gt; Opens the web app to look and feel like a standalone native app. The app runs in its own window, separate from the browser, and hides standard browser UI elements like the URL bar.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;minimal-ui:&lt;/em&gt; This mode is similar to standalone, but provides the user a minimal set of UI elements for controlling navigation (such as back and reload).&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;browser:&lt;/em&gt;    A standard browser experience.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;theme_color: &lt;/strong&gt;
The theme_color sets the color of the tool bar.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Offline capabilities
&lt;/h2&gt;

&lt;p&gt;Adding the service-worker.js gives the app the offline capability that it requires to work like a native app.&lt;br&gt;
When the app is launched the service worker will look for the page/component to be served from the cache, if it was not available in cache then it tries to reach the server for the request to be served. This is the strategy followed irrespective of connectivity being present or not.&lt;/p&gt;

&lt;p&gt;Since this logic is baked into service worker js, if any URL in the app is to be always served from the server (like a server rendered page) then edits need to be done into service worker js onFetch method.&lt;/p&gt;

&lt;p&gt;For any data that is served from the page will be directed to the server, so an offline capability has to be handled by the app developer either by using a localstorage or an indexDB for storing data at client side or presenting user with no connectivity message.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference links
&lt;/h2&gt;

&lt;p&gt;All PWA concepts like manifest.json, service worker js, local storage, push notification are web standards independent of Blazor. Blazor has brought these webconcepts, webassembly and our beloved C# &amp;amp; Razor together.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Service Worker: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"&gt;https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Manifest.json: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Manifest"&gt;https://developer.mozilla.org/en-US/docs/Web/Manifest&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Blazor: &lt;a href="https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor"&gt;https://dotnet.microsoft.com/apps/aspnet/web-apps/blazor&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blazor</category>
      <category>webassembly</category>
      <category>c</category>
      <category>progressivewebapp</category>
    </item>
    <item>
      <title>An attempt to convert Blazor WebAssembly Project to Blazor Server App</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Sat, 25 Apr 2020 02:02:19 +0000</pubDate>
      <link>https://dev.to/gopkumr/an-attempt-to-convert-blazor-webassembly-project-to-blazor-server-app-276i</link>
      <guid>https://dev.to/gopkumr/an-attempt-to-convert-blazor-webassembly-project-to-blazor-server-app-276i</guid>
      <description>&lt;h2&gt;
  
  
  Blazor Web-Assembly Project
&lt;/h2&gt;

&lt;p&gt;This starts from my Blazor Web-Assembly project that I create as a replica of the Angular TourOfHeros tutorial. The source code of project is in &lt;a href="https://github.com/gopkumr/BlazorTourOfHeroes.git"&gt;GitHub&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;This is an attempt to convert the existing project to a Blazor server app with few changes to the wiring up and hosting configuration. Since this article is written with a pre-release version of Blazor Web-Assembly, there could be changes to the steps after the actual release expected in May 2020.&lt;/p&gt;

&lt;h2&gt;
  
  
  Framework updates
&lt;/h2&gt;

&lt;p&gt;The WebAssembly project was create in Jan 2020 when the Blazor Web-Assembly project was in preview, hence i have to change the TargetFramework and few assembly references in the project file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Updated Target Framework to &lt;code&gt;netcoreapp3.1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Removed references to Blazor assemblies from .Net Core 3.1.0-Preview build&lt;/li&gt;
&lt;li&gt;Removed &lt;code&gt;RazorLanguageVersion&lt;/code&gt; specification&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Hosting and Startup changes
&lt;/h2&gt;

&lt;p&gt;We need to added references to couple of Framework assemblies, namely &lt;code&gt;Microsoft.AspNetCore.App&lt;/code&gt; and &lt;code&gt;Microsoft.NETCore.App&lt;/code&gt; which provides the BlazorServer components.&lt;/p&gt;

&lt;p&gt;To wire up Blazor Server app we first need to configure the dependency injection container. This is done by adding server side Blazor service in startup class's &lt;code&gt;ConfigureServices&lt;/code&gt; method&lt;br&gt;
&lt;code&gt;services.AddServerSideBlazor()&lt;/code&gt;&lt;br&gt;
Also add support for Razor pages &lt;code&gt;services.AddRazorPages()&lt;/code&gt;, because, our Blazor components are Razor pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring the request pipeline
&lt;/h3&gt;

&lt;p&gt;Unlike the Web-Assembly where we just bootstrap the first component and routing is performed at browser end, the Blazor server integrates with ASPNet Core routing and it uses BlazorHub to interact with Blazor components. For this we add the below configurations to the Configure method.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;app.UseStaticFiles();&lt;br&gt;
  app.UseRouting();&lt;br&gt;
  app.UseEndpoints(endpoints =&amp;gt;&lt;br&gt;
    {&lt;br&gt;
     endpoints.MapBlazorHub();&lt;br&gt;
     endpoints.MapFallbackToPage("/_Host");&lt;br&gt;
    });&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;All the requests are directed to a Blazor component based on the URL defined using the @page directive, any URL that does not have a match in the routing configured to directed to the fallback page.&lt;br&gt;
The &lt;code&gt;MapFallbackToPage&lt;/code&gt; is used to define the component to be loaded when the request does not match any URL. The host file is named _host by-convention also this route has a lower priority in the routing table, hence Blazor can be coexist with other ASPNet core pages/controllers without causing conflicts. &lt;/p&gt;

&lt;h2&gt;
  
  
  _Host file
&lt;/h2&gt;

&lt;p&gt;Since the host file is loaded by default in our project &lt;em&gt;(since we don't have any another routes configured)&lt;/em&gt;, the code that we had in our &lt;code&gt;index.html&lt;/code&gt; will need to be copied over to the host file along with couple lines of code modified.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The JavaScript file supporting web assembly needs to be changed to the one 
supporting Blazor server
i.e. &lt;code&gt;&amp;lt;script src="_framework/blazor.server.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Rendering mode of the initial component to be changed to server-pre-rendered
&lt;code&gt;&amp;lt;app&amp;gt;Loading...&amp;lt;/app&amp;gt;&lt;/code&gt;
to
&lt;code&gt;&amp;lt;app&amp;gt; &amp;lt;component type="typeof(App)" render-mode="ServerPrerendered" /&amp;gt;&amp;lt;/app&amp;gt;&lt;/code&gt;
&lt;em&gt;We can pretty much bootstrap any component in the type attribute, we use the 
App component as it is our parent component which calls all the rest of the 
components.&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's pretty much it. Your WebAssembly app should be able to running in a ServerRendered Blazor server mode now. &lt;/p&gt;

&lt;p&gt;Both my WebAssembly and Blazor Server app code are available in &lt;a href="https://github.com/gopkumr/BlazorTourOfHeroes.git"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WebAssembly is in the &lt;code&gt;master&lt;/code&gt; branch&lt;/li&gt;
&lt;li&gt;BlazorServer is in the &lt;code&gt;serverApp&lt;/code&gt; branch &lt;em&gt;(which i branched out and modified)&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blazor</category>
      <category>webassembly</category>
      <category>blazorserverapp</category>
    </item>
    <item>
      <title>Tired of updating namespaces? With VS2019 you won't.</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Fri, 11 Oct 2019 09:26:47 +0000</pubDate>
      <link>https://dev.to/gopkumr/adjust-namespaces-automatically-visual-studio-2019-1f0b</link>
      <guid>https://dev.to/gopkumr/adjust-namespaces-automatically-visual-studio-2019-1f0b</guid>
      <description>&lt;p&gt;Most of us programmers would have moved code files around to different folders at a different stages of the application development, this might be due to refactoring or redesigning or re-organizing. While moving around the code files, most .Net developers would have spent enough time changing the namespaces to match the folder structure (as better practice).&lt;/p&gt;

&lt;p&gt;With Visual Studio 2019, this mundane task of changing the namespaces while moving folder is now automated, which means, visual studio updates the namespace to match the folder structure by itself. &lt;br&gt;
Even if for some reason, you move the folder using the file explorer rather than the visual studio, in such case, you can go into the code file and you get an option to update the namespace to match the folder structure or change it any other existing namespace from your project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--q-xYIGje--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/82q32fxgct4ywxayk8pt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q-xYIGje--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/82q32fxgct4ywxayk8pt.png" alt="Namespace change option"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cool isn't it.&lt;/p&gt;

</description>
      <category>visualstudio2019</category>
    </item>
    <item>
      <title>A brave move by Brave</title>
      <dc:creator>gopkumr</dc:creator>
      <pubDate>Sun, 29 Sep 2019 09:48:58 +0000</pubDate>
      <link>https://dev.to/gopkumr/a-brave-move-by-brave-3a60</link>
      <guid>https://dev.to/gopkumr/a-brave-move-by-brave-3a60</guid>
      <description>&lt;p&gt;&lt;strong&gt;Current online ads landscape&lt;/strong&gt;&lt;br&gt;
Advertisers and publishers are always in search of targeting the right user group and the actual presenting of ads to the user. Users are the most undervalued actor of the use case. The ads intrude into the viewing area, uses up bandwidth, make the overall experience poor. In most cases, the users enjoy the service for free by viewing the ads e.g. Youtube. &lt;/p&gt;

&lt;p&gt;Brave browser has taken this use case and improvised to make it a win-win situation for all. Here is what Brave has done.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Brave Browser&lt;/strong&gt;&lt;br&gt;
Brave itself is an open-sourced browser specialized in ad and website tracker blocking and private browsing capabilities. And it does it efficiently.&lt;/p&gt;

&lt;h4&gt;
  
  
  Now to get to the technology behind brave.
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Brave&lt;/em&gt; is Google's Chromium web browser like other browsers like chrome, partners with search engine &lt;a href="https://duckduckgo.com/" rel="noopener noreferrer"&gt;DuckDuckGo&lt;/a&gt;. The browser has added &lt;a href="https://en.wikipedia.org/wiki/Tor_(anonymity_network)" rel="noopener noreferrer"&gt;Tor&lt;/a&gt; for private browsing. The browser has combined its capability with a blockchain-based platform to connect the advertisers with the consumers with no multilayered middlemen. The network that brave would connect to is the first of its kind blockchain-based digital advertising platform called &lt;a href="https://tapnetwork.io/" rel="noopener noreferrer"&gt;TAP network&lt;/a&gt;. Braves network is based on Etherium blockchain and it uses a token Called Basic Attention Tokens (BAT) as the cryptocurrency for rewards for the users or viewers of the ads. The browser gives users an option to opt-in viewing ads and only those users will see ads as a notification separated from the content that they are viewing. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fl1qyplwfdk57d4w3tlyj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fl1qyplwfdk57d4w3tlyj.png" alt="Brave Ad"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Brave Ads are shown to the user based on the data that is stored locally to the user's browser and hence it does not require a remote tracking system and users data to be sent out.&lt;br&gt;
The browser also gives you the option to choose how frequently you want to view the ad. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fphzgvuj4plyezu11s3xc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fphzgvuj4plyezu11s3xc.png" alt="BAT Network"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This use-case of online advertisement implementation on top of a blockchain network is clearly a disruptive one that opens up a lot of possibilities. The token that users collect can be claimed back as any fiat currency or tip content writers, encouraging them to produce more quality content. At the time of writing 1 BAT (0.00093990 ETH) = USD 0.160672.  &lt;/p&gt;

</description>
      <category>browser</category>
      <category>blockchain</category>
      <category>ads</category>
      <category>rewards</category>
    </item>
  </channel>
</rss>
