<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Solopreneur on Medium]]></title>
        <description><![CDATA[Stories by Solopreneur on Medium]]></description>
        <link>https://medium.com/@mrkevin-wang?source=rss-661d1808be74------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*78Cd7gCoYKfJbSKg.jpg</url>
            <title>Stories by Solopreneur on Medium</title>
            <link>https://medium.com/@mrkevin-wang?source=rss-661d1808be74------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 00:30:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mrkevin-wang/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Terraform CDK can fill the Gap Between Code and Infrastructure]]></title>
            <link>https://mrkevin-wang.medium.com/terraform-cdk-can-fill-the-gap-between-code-and-infrastructure-6bc2a6f22abb?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/6bc2a6f22abb</guid>
            <category><![CDATA[iac]]></category>
            <category><![CDATA[terraform-cdk]]></category>
            <category><![CDATA[cloud-infrastructure]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 00:57:31 GMT</pubDate>
            <atom:updated>2025-03-11T00:57:31.944Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you use terraform to manage your cloud infrastructures? Do you use services from multi clouds? Do you find a lot of times you are wrestling with Iac to manage cloud resources trying to apply complex logics?</p><p>That’s where the Terraform Cloud Development Kit (CDK) steps in — a game changer for anyone who loves the power of code and the precision of infrastructure.</p><p>Let’s be honest — HashiCorp Configuration Language (HCL) is great for declarative infrastructure definitions, but it has its limits. When you start needing complex logic, like loops, conditionals, or reusing components efficiently, HCL starts to feel like you’re squeezing logic into a language that wasn’t designed for it.</p><p>Terraform CDK allows you to use your preferred language, like C#, Java, Go, Python, etc.</p><p>So you can leverage existing programming concepts and design patterns to make your code more efficient, plus code reusability and easier integrations to CI/CD pipelines.</p><h3>A Real-World Example</h3><p>In one of my recent projects, we needed to spin up a dynamic number of S3 buckets in AWS, each tied to a specific environment. In HCL, this would have required some clever use of count or for_each, but with CDKTF in TypeScript, it looked like this:</p><pre>import * as cdktf from &#39;cdktf&#39;;<br>import * as aws from &#39;@cdktf/provider-aws&#39;;<br><br>class MyStack extends cdktf.TerraformStack {<br>  constructor(scope: cdktf.App, id: string) {<br>    super(scope, id);<br><br>    const environments = [&#39;dev&#39;, &#39;staging&#39;, &#39;prod&#39;];<br><br>    environments.forEach(env =&gt; {<br>      new aws.s3Bucket.S3Bucket(this, `MyBucket-${env}`, {<br>        bucket: `my-app-${env}-bucket`,<br>      });<br>    });<br>  }<br>}<br><br>const app = new cdktf.App();<br>new MyStack(app, &#39;MyStack&#39;);<br>app.synth();</pre><p>In less than 20 lines of code, we generated multiple buckets with environment-specific names. The same logic in HCL would have been far more verbose and less intuitive.</p><p>Another key advantage of Terraform CDK is how smoothly it integrates with existing Terraform workflows. You’re not throwing away your Terraform modules — CDKTF simply compiles your code into standard Terraform JSON, meaning you can:</p><ul><li>Continue using existing Terraform providers and modules.</li><li>Leverage the full Terraform ecosystem.</li><li>Adopt CDK incrementally without a painful migration.</li></ul><h3>Downsides</h3><p>Of course, no tool is perfect. Terraform CDK does add another layer of abstraction, which can make debugging trickier. The generated JSON can be verbose, and sometimes you need to dive into both the generated code and the Terraform output to figure out what went wrong.</p><p>Maybe some learning curves for your teams, not all team members are comfortable with the programming languages used.</p><p>But Terraform CDK is not aiming to replacing Terraform, it is about extending it to handle more complexing jobs in an easier way.</p><p>It may not be for everyone, but give it a go in some experiments and see how you go with it!</p><p>Enjoy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6bc2a6f22abb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apply BDD test automation with Reqnroll + Test Containers for you event driven designs]]></title>
            <link>https://mrkevin-wang.medium.com/apply-bdd-test-automation-with-reqnroll-test-containers-for-you-event-driven-designs-578f39fc935c?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/578f39fc935c</guid>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[testcontainer]]></category>
            <category><![CDATA[azure-event-hub]]></category>
            <category><![CDATA[azurite]]></category>
            <category><![CDATA[bdd-development]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Thu, 16 Jan 2025 01:17:25 GMT</pubDate>
            <atom:updated>2025-01-16T01:17:25.163Z</atom:updated>
            <content:encoded><![CDATA[<h3>prerequisites</h3><ul><li>Reqnroll</li><li>Test Containers</li><li>event hub emulator</li></ul><h3>Use case</h3><p>Just imagine you tech stack is on Azure, and the whole system is designed as microservices with event driven design using event hubs.</p><p>We will make it simple enough for POC that you only have a publisher app that is publishing price update events to Azure Event Hubs, and a consumer app is consuming the price updates from Event Hubs.</p><p>You already have DEV, UAT, PT, PROD environments setup in Azure, but they are being used for different purposes of testing.</p><p>Let’s say if you use DEV for your BDD test automation, and enable the automation to be run in your CI/CD pipelines. You could get the pipeline fails often when someone is testing with the DEV environment and publishing some events with different values etc.</p><p>With test containers and emulators that you can isolate your BDD automation in its docker environments and always get the consistent test results.</p><h3>Now Let’s work on it</h3><p>First, let’s create a Reqnroll project. Create our first feature file:</p><pre>@pricingfeature<br>Feature: Pricing<br><br>Simple calculator for adding two numbers<br><br>@recievedpricing<br>Scenario: Received Pricing Event<br> Given an price event is published for &quot;101202&quot; with price 55.65<br> And wait for some time<br> When an price event is consumed<br> Then the price should be saved for article &quot;101202&quot; with price 55.65</pre><pre>[Binding]<br>public sealed class PricingStepDefinitions : GlobalStepDefinitions<br>{<br>    // For additional details on Reqnroll step definitions see https://go.reqnroll.net/doc-stepdef<br>    private FeatureContext _featureContext;<br><br>    public PricingStepDefinitions(FeatureContext featureContext)<br>    {<br>        _featureContext = featureContext;<br>    }<br><br>    // Before and After Feature hooks<br>    [BeforeFeature(&quot;pricingfeature&quot;)]<br>    public static async Task BeforeFeature(FeatureContext featureContext)<br>    {<br>        Console.WriteLine(&quot;Starting &quot; + featureContext.FeatureInfo.Title);<br>    }<br><br>    [AfterFeature(&quot;pricingfeature&quot;)]<br>    public static async Task AfterFeature(FeatureContext featureContext)<br>    {<br>        Console.WriteLine(&quot;Finished &quot; + featureContext.FeatureInfo.Title);<br>    }<br><br>    // Before and After Scenario hooks<br>    [BeforeScenario(&quot;recievedpricing&quot;)]<br>    public async Task BeforeScenario()<br>    {<br>        Console.WriteLine(&quot;Starting &quot; + ScenarioContext.Current.ScenarioInfo.Title);        <br>    }<br><br>    [AfterScenario(&quot;recievedpricing&quot;)]<br>    public async Task AfterScenario()<br>    {<br>        Console.WriteLine(&quot;Finished &quot; + ScenarioContext.Current.ScenarioInfo.Title);        <br>    }<br><br>    [Given(&quot;an price event is published for {string} with price {double}&quot;)]<br>    public async Task GivenPriceIsPublished(string articleId, double price)<br>    {<br>        //TODO call your publisher to publish pricing events<br>    }<br><br>    [Given(&quot;wait for some time&quot;)]<br>    public async Task GivenWaitForSomeTime()<br>    {<br>        await Task.Delay(3000);<br>    }<br><br>    [When(&quot;an price event is consumed&quot;)]<br>    public async Task WhenTheTwoNumbersAreAdded()<br>    {<br>        //TODO consume the events that were published<br>    }<br><br>    [Then(&quot;the price should be saved for article {string} with price {double}&quot;)]<br>    public void ThenTheResultShouldBe(string articleId, double price)<br>    {<br>        //TODO verify the events<br>    }<br>}</pre><p>As you can see the code above, I have defined a <strong>GlobalStepDefinitions </strong>where I want to put my setup codes for test containers.</p><p>You need to install these two nuget packages, as test containers already have a module for Azurite, we could just use their implementation.</p><pre>dotnet add package Testcontainers --version 4.1.0<br>dotnet add package Testcontainers.Azurite --version 4.1.0</pre><p>Once you installed these two nuget packages, we will be using them later.</p><h4>Working on the event hub emulators</h4><p>If you haven’t played around with event hub emulators yet, you can checkout this <a href="https://mrkevin-wang.medium.com/find-out-how-event-hub-emulator-helps-with-local-development-8a5f5a50189d">article </a>to get you started.</p><p>We want to create one event hub with one consumer group, to keep it simple for POC purpose I will only have one partition as well.</p><p>Here is the json config file for it.</p><pre>{<br>  &quot;UserConfig&quot;: {<br>    &quot;NamespaceConfig&quot;: [<br>      {<br>        &quot;Type&quot;: &quot;EventHub&quot;,<br>        &quot;Name&quot;: &quot;emulatorNs1&quot;,<br>        &quot;Entities&quot;: [<br>          {<br>            &quot;Name&quot;: &quot;pricing-service-delta&quot;,<br>            &quot;PartitionCount&quot;: &quot;1&quot;,<br>            &quot;ConsumerGroups&quot;: [<br>              {<br>                &quot;Name&quot;: &quot;pricing-delta-cg&quot;<br>              }<br>            ]<br>          }<br>        ]<br>      }<br>    ],<br>    &quot;LoggingConfig&quot;: {<br>      &quot;Type&quot;: &quot;File&quot;<br>    }<br>  }<br>}</pre><p>Because Test Containers don’t have an existing module for event hub emulators yet. With the event hub emulator container, we will need to configure and build it as IContainer.</p><pre>// I need to get the absolute path of the event hub config file<br>var absolutePath = Path.Combine(Directory.GetCurrentDirectory(), &quot;Config.json&quot;);<br><br>var eventHubContainerName = &quot;my-event-hub&quot;;<br>    _eventHubContainer = new ContainerBuilder()<br>        .WithImage(&quot;mcr.microsoft.com/azure-messaging/eventhubs-emulator:latest&quot;)<br>        .WithName(eventHubContainerName)<br>        .WithPortBinding(5672, 5672)<br>        .WithBindMount(absolutePath, &quot;/Eventhubs_Emulator/ConfigFiles/Config.json&quot;)<br>        .WithWaitStrategy(<br>            Wait.ForUnixContainer()<br>                .UntilMessageIsLogged(&quot;.*Emulator Service is Successfully Up!.*&quot;,<br>                    o =&gt; o.WithTimeout(TimeSpan.FromSeconds(30))))<br>        .WithNetwork(_network)<br>        .WithEnvironment(&quot;BLOB_SERVER&quot;, azuriteContainerName)<br>        .WithEnvironment(&quot;METADATA_SERVER&quot;, azuriteContainerName)<br>        .WithEnvironment(&quot;ACCEPT_EULA&quot;, &quot;Y&quot;)<br>        .DependsOn(_azuriteContainer)<br>    .Build();</pre><p>Here is the completed code of <strong>GlobalStepDefinitions. </strong>It contains StartAllContainers() and ShutdownAllContainers() methods, that will be called before feature starts and after feature ends.</p><pre>public class GlobalStepDefinitions<br>{<br>    private readonly AzuriteContainer _azuriteContainer;<br>    private readonly IContainer _eventHubContainer;<br>    private readonly INetwork _network;<br><br>    public GlobalStepDefinitions()<br>    {<br>        var networkName = &quot;my-network&quot;;<br>        _network = new NetworkBuilder()<br>            .WithName(networkName)<br>            .Build();<br><br>        var azuriteContainerName = &quot;my-azurite&quot;;<br>        _azuriteContainer = new AzuriteBuilder()<br>            .WithImage(&quot;mcr.microsoft.com/azure-storage/azurite:latest&quot;)<br>            .WithName(azuriteContainerName)<br>            .WithPortBinding(10000, 10000)<br>            .WithPortBinding(10001, 10001)<br>            .WithPortBinding(10002, 10002)<br>            .WithNetwork(_network)<br>            .Build();<br><br>        // I need to get the absolute path of the event hub config file<br>        var absolutePath = Path.Combine(Directory.GetCurrentDirectory(), &quot;Config.json&quot;);<br><br>        var eventHubContainerName = &quot;my-event-hub&quot;;<br>        _eventHubContainer = new ContainerBuilder()<br>            .WithImage(&quot;mcr.microsoft.com/azure-messaging/eventhubs-emulator:latest&quot;)<br>            .WithName(eventHubContainerName)<br>            .WithPortBinding(5672, 5672)<br>            .WithBindMount(absolutePath, &quot;/Eventhubs_Emulator/ConfigFiles/Config.json&quot;)<br>            .WithWaitStrategy(<br>                Wait.ForUnixContainer()<br>                    .UntilMessageIsLogged(&quot;.*Emulator Service is Successfully Up!.*&quot;,<br>                        o =&gt; o.WithTimeout(TimeSpan.FromSeconds(30))))<br>            .WithNetwork(_network)<br>            .WithEnvironment(&quot;BLOB_SERVER&quot;, azuriteContainerName)<br>            .WithEnvironment(&quot;METADATA_SERVER&quot;, azuriteContainerName)<br>            .WithEnvironment(&quot;ACCEPT_EULA&quot;, &quot;Y&quot;)<br>            .DependsOn(_azuriteContainer)<br>        .Build();<br>    }<br><br>    public async Task StartAllContainers()<br>    {<br>        await _network.CreateAsync()<br>            .ConfigureAwait(false);<br><br>        await _azuriteContainer.StartAsync()<br>            .ConfigureAwait(false);<br><br>        await _eventHubContainer.StartAsync()<br>            .ConfigureAwait(false);<br>    }<br><br>    public async Task ShutdownAllContainers()<br>    {<br>        await _eventHubContainer.StopAsync()<br>            .ConfigureAwait(false);<br><br>        await _azuriteContainer.StopAsync()<br>            .ConfigureAwait(false);<br><br>        await _network.DeleteAsync()<br>            .ConfigureAwait(false);<br>    }</pre><p>We need some Test Publisher and Test Consumer to simulate pricing events publishing and consuming. This will be replaced with your app in real world scenario.</p><h4>Test Connection Configuration Model</h4><pre>public class PricingDeltaConfig<br>{<br>    public string ConnectionString { get; set; }<br>    public string HubName { get; set; }<br>    public string ConsumerGroupName { get; set; }<br>}</pre><p>Connection string you can use the default:</p><pre>&quot;Endpoint=sb://localhost;SharedAccessKeyName=RootManageSharedAccessKey;&quot; +<br>&quot;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;&quot;</pre><h4>Test Message Model</h4><pre>public class ProductPricingTestMessage<br>{<br>    public string ProductId { get; set; }<br>    public double? UnitPrice { get; set; }<br>    public DateTime? LastUpdatedDate { get; set; }<br>}</pre><h4>Test Publisher</h4><pre>public interface IPricingDeltaTestPublisher<br>{<br>    Task Send(ProductPricingTestMessage pricing);<br>}<br><br>public class PricingDeltaTestPublisher : IPricingDeltaTestPublisher<br>{<br>    private readonly PricingDeltaConfig _articlePricingDeltaConfig;<br><br>    public PricingDeltaTestPublisher(PricingDeltaConfig config)<br>    {<br>        _articlePricingDeltaConfig = config;<br>    }<br><br>    public async Task Send(ProductPricingTestMessage pricing)<br>    {<br>        EventHubProducerClient producerClient = new EventHubProducerClient(_articlePricingDeltaConfig.ConnectionString, _articlePricingDeltaConfig.HubName);<br><br>        // Create a batch of events <br>        using EventDataBatch pricingEventBatch = await producerClient.CreateBatchAsync();<br><br>        var eventData = BuildEventData(pricing);<br>        eventData.Properties.Add(&quot;product_key&quot;, $&quot;{pricing.ProductId}&quot;);<br>        if (!pricingEventBatch.TryAdd(eventData))<br>        {<br>            // if it is too large for the batch<br>            throw new Exception($&quot;failed to add event to pricing batch.&quot;);<br>        }<br><br>        try<br>        {<br>            // Use the producer client to send the batch of events to the event hub<br>            await producerClient.SendAsync(pricingEventBatch);<br>            Console.WriteLine($&quot;A pricing event articleID:{pricing.ProductId} has been published.&quot;);<br>        }<br>        finally<br>        {<br>            await producerClient.DisposeAsync();<br>        }<br>    }<br><br>    private EventData BuildEventData(ProductPricingTestMessage testMessage)<br>    {<br>        var pricing = new Pricing<br>        {<br>            UnitPrice = testMessage.UnitPrice,<br>            ReferenceNumber = testMessage.ProductId,<br>            CreatedDateTimeUtc = DateTime.UtcNow.ToTimestamp()<br>        };<br>    <br>        var json = JsonConvert.SerializeObject(pricing);<br>        var eventData = new EventData(json);<br>        return eventData;<br>    }<br>}</pre><h4>Test Consumer</h4><pre>public interface IPricingDeltaTestConsumer<br>{<br>    Task&lt;List&lt;ProductPricingTestMessage&gt;&gt; Receive();<br>}<br><br>public class PricingDeltaTestConsumer : IPricingDeltaTestConsumer<br>{<br>    private readonly PricingDeltaConfig _articlePricingDeltaConfig;<br><br>    public PricingDeltaTestConsumer(PricingDeltaConfig config)<br>    {<br>        _articlePricingDeltaConfig = config;<br>    }<br><br>    public async Task&lt;List&lt;ProductPricingTestMessage&gt;&gt; Receive()<br>    {<br>        var consumer = new EventHubConsumerClient(_articlePricingDeltaConfig.ConsumerGroupName,<br>            _articlePricingDeltaConfig.ConnectionString, _articlePricingDeltaConfig.HubName);<br><br>        var partitionEvents = consumer.ReadEventsAsync(new ReadEventOptions { MaximumWaitTime = TimeSpan.FromSeconds(2) });<br><br>        var results = new ConcurrentBag&lt;ProductPricingTestMessage&gt;();<br>        await foreach (PartitionEvent partitionEvent in partitionEvents)<br>        {<br>            if (partitionEvent.Data == null)<br>            {<br>                break;<br>                <br>            }<br><br>            string json = Encoding.UTF8.GetString(partitionEvent.Data.EventBody.ToArray());<br>            var pricing = JsonConvert.DeserializeObject&lt;ProductPricingTestMessage&gt;(json);<br>            results.Add(pricing);<br>        }<br><br>        return results.ToList();<br>    }<br>}</pre><p>Let’s get back to our <strong>PricingStepDefinitions</strong> and complete the TODO methods.</p><pre>[Given(&quot;an price event is published for {string} with price {double}&quot;)]<br>public async Task GivenPriceIsPublished(string articleId, double price)<br>{<br>    var testMessage = new ProductPricingTestMessage();<br>    testMessage.ProductId = articleId;<br>    testMessage.UnitPrice = price;<br>    testMessage.LastUpdatedDate = DateTime.UtcNow;<br><br>    var publisher = new PricingDeltaTestPublisher(new PricingDeltaConfig<br>    {<br>        ConnectionString = EventHubNamespaceConnectionString,<br>        HubName = &quot;pricing-service-delta&quot;,<br>        ConsumerGroupName = &quot;pricing-delta-cg&quot;<br>    });<br><br>    await publisher.Send(testMessage);<br>}</pre><pre>[When(&quot;an price event is consumed&quot;)]<br>public async Task WhenTheTwoNumbersAreAdded()<br>{<br>    var consumer = new PricingDeltaTestConsumer(new PricingDeltaConfig<br>    {<br>        ConnectionString = EventHubNamespaceConnectionString,<br>        HubName = &quot;pricing-service-delta&quot;,<br>        ConsumerGroupName = &quot;pricing-delta-cg&quot;<br>    });<br><br>    var events = await consumer.Receive();<br>    _featureContext.Set(events, &quot;pricing-events&quot;);<br>}</pre><pre>[Then(&quot;the price should be saved for article {string} with price {double}&quot;)]<br>public void ThenTheResultShouldBe(string articleId, double price)<br>{<br>    _featureContext.TryGetValue&lt;List&lt;Pricing&gt;&gt;(&quot;pricing-events&quot;, out var events);<br>    events.Should().NotBeNull();<br>    events.Should().HaveCount(1);<br>    events[0].ReferenceNumber.Should().Be(articleId);<br>    events[0].UnitPrice.Should().Be(price);<br>}</pre><h3>Finally</h3><p>when you do dotnet test, it will execute your features and scenarios. If you take a look at the docker ps, you would see test containers spin up a few containers to support the automation tests.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=578f39fc935c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Long waited service bus emulator]]></title>
            <link>https://mrkevin-wang.medium.com/long-waited-service-bus-emulator-7f026a2bc174?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f026a2bc174</guid>
            <category><![CDATA[azure-service-bus]]></category>
            <category><![CDATA[emulator]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[event-driven-systems]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Thu, 09 Jan 2025 04:31:13 GMT</pubDate>
            <atom:updated>2025-01-09T04:31:13.664Z</atom:updated>
            <content:encoded><![CDATA[<h3>Here it is: the long waited service bus emulator</h3><p><a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/overview-emulator">Overview of the Azure Service Bus emulator - Azure Service Bus</a></p><p>How long have you been expecting the service bus emulator, it is now finally here :)</p><p>Although there are still some limitations, but for most of scenarios those can be satisfied. The limitations are:</p><ul><li>It can’t stream messages by using the JMS protocol.</li><li>Partitioned entities aren’t compatible with emulator.</li><li>It doesn’t support on-the-fly management operations through a client-side SDK.</li></ul><p>Microsoft has provided an service bus emulator to help with the following aspects:</p><ul><li>Local development: The emulator provides a local development experience, so you can work offline and avoid network latency.</li><li>Cost efficiency: With the emulator, you can test your applications without incurring any cloud usage costs.</li><li>Isolated testing environment: You can test your code in isolation, to help ensure that other activities in the cloud don’t affect the tests.</li><li>Optimized inner development loop: You can use the emulator to quickly prototype and test your applications before deploying them to the cloud.</li></ul><h3>Using emulator with docker-compose</h3><ol><li>To start the emulator, supply a configuration for the entities that you want to use. Save the following JSON file locally as <em>config.json</em>:</li></ol><pre>{<br>    &quot;UserConfig&quot;: {<br>      &quot;Namespaces&quot;: [<br>        {<br>          &quot;Name&quot;: &quot;sbemulatorns&quot;,<br>          &quot;Queues&quot;: [<br>            {<br>              &quot;Name&quot;: &quot;queue.1&quot;,<br>              &quot;Properties&quot;: {<br>                &quot;DeadLetteringOnMessageExpiration&quot;: false,<br>                &quot;DefaultMessageTimeToLive&quot;: &quot;PT1H&quot;,<br>                &quot;DuplicateDetectionHistoryTimeWindow&quot;: &quot;PT20S&quot;,<br>                &quot;ForwardDeadLetteredMessagesTo&quot;: &quot;&quot;,<br>                &quot;ForwardTo&quot;: &quot;&quot;,<br>                &quot;LockDuration&quot;: &quot;PT1M&quot;,<br>                &quot;MaxDeliveryCount&quot;: 10,<br>                &quot;RequiresDuplicateDetection&quot;: false,<br>                &quot;RequiresSession&quot;: false<br>              }<br>            }<br>          ],<br>          &quot;Topics&quot;: [<br>            {<br>              &quot;Name&quot;: &quot;topic.1&quot;,<br>              &quot;Properties&quot;: {<br>                &quot;DefaultMessageTimeToLive&quot;: &quot;PT1H&quot;,<br>                &quot;DuplicateDetectionHistoryTimeWindow&quot;: &quot;PT20S&quot;,<br>                &quot;RequiresDuplicateDetection&quot;: false<br>              },<br>              &quot;Subscriptions&quot;: [<br>                {<br>                  &quot;Name&quot;: &quot;subscription.1&quot;,<br>                  &quot;Properties&quot;: {<br>                    &quot;DeadLetteringOnMessageExpiration&quot;: false,<br>                    &quot;DefaultMessageTimeToLive&quot;: &quot;PT1H&quot;,<br>                    &quot;LockDuration&quot;: &quot;PT1M&quot;,<br>                    &quot;MaxDeliveryCount&quot;: 10,<br>                    &quot;ForwardDeadLetteredMessagesTo&quot;: &quot;&quot;,<br>                    &quot;ForwardTo&quot;: &quot;&quot;,<br>                    &quot;RequiresSession&quot;: false<br>                  },<br>                  &quot;Rules&quot;: [<br>                    {<br>                      &quot;Name&quot;: &quot;app-prop-filter-1&quot;,<br>                      &quot;Properties&quot;: {<br>                        &quot;FilterType&quot;: &quot;Correlation&quot;,<br>                        &quot;CorrelationFilter&quot;: {<br>                          &quot;ContentType&quot;: &quot;application/text&quot;,<br>                          &quot;CorrelationId&quot;: &quot;id1&quot;,<br>                          &quot;Label&quot;: &quot;subject1&quot;,<br>                          &quot;MessageId&quot;: &quot;msgid1&quot;,<br>                          &quot;ReplyTo&quot;: &quot;someQueue&quot;,<br>                          &quot;ReplyToSessionId&quot;: &quot;sessionId&quot;,<br>                          &quot;SessionId&quot;: &quot;session1&quot;,<br>                          &quot;To&quot;: &quot;xyz&quot;<br>                        }<br>                      }<br>                    }<br>                  ]<br>                },<br>                {<br>                  &quot;Name&quot;: &quot;subscription.2&quot;,<br>                  &quot;Properties&quot;: {<br>                    &quot;DeadLetteringOnMessageExpiration&quot;: false,<br>                    &quot;DefaultMessageTimeToLive&quot;: &quot;PT1H&quot;,<br>                    &quot;LockDuration&quot;: &quot;PT1M&quot;,<br>                    &quot;MaxDeliveryCount&quot;: 10,<br>                    &quot;ForwardDeadLetteredMessagesTo&quot;: &quot;&quot;,<br>                    &quot;ForwardTo&quot;: &quot;&quot;,<br>                    &quot;RequiresSession&quot;: false<br>                  },<br>                  &quot;Rules&quot;: [<br>                    {<br>                      &quot;Name&quot;: &quot;user-prop-filter-1&quot;,<br>                      &quot;Properties&quot;: {<br>                        &quot;FilterType&quot;: &quot;Correlation&quot;,<br>                        &quot;CorrelationFilter&quot;: {<br>                          &quot;Properties&quot;: {<br>                            &quot;prop3&quot;: &quot;value3&quot;<br>                          }<br>                        }<br>                      }<br>                    }<br>                  ]<br>                },<br>                {<br>                  &quot;Name&quot;: &quot;subscription.3&quot;,<br>                  &quot;Properties&quot;: {<br>                    &quot;DeadLetteringOnMessageExpiration&quot;: false,<br>                    &quot;DefaultMessageTimeToLive&quot;: &quot;PT1H&quot;,<br>                    &quot;LockDuration&quot;: &quot;PT1M&quot;,<br>                    &quot;MaxDeliveryCount&quot;: 10,<br>                    &quot;ForwardDeadLetteredMessagesTo&quot;: &quot;&quot;,<br>                    &quot;ForwardTo&quot;: &quot;&quot;,<br>                    &quot;RequiresSession&quot;: false<br>                  }<br>                }<br>              ]<br>            }<br>          ]<br>        }<br>      ],<br>      &quot;Logging&quot;: {<br>        &quot;Type&quot;: &quot;File&quot;<br>      }<br>    }<br>  }</pre><p>In the above config file for the emulator, I specified:</p><ul><li>one service bus queue</li><li>one service bus topic</li><li>three service bus subscriptions</li></ul><p>2. Now we need to create a service using docker-compose to start this service-bus emulator. sql-edge will be required for the emulator to work.</p><pre>name: microsoft-azure-servicebus-emulator<br>services:<br>  emulator:<br>    container_name: &quot;servicebus-emulator&quot;<br>    image: mcr.microsoft.com/azure-messaging/servicebus-emulator:latest<br>    volumes:<br>      - &quot;./config.json:/ServiceBus_Emulator/ConfigFiles/Config.json&quot;<br>    ports:<br>      - &quot;5672:5672&quot;<br>    environment:<br>      SQL_SERVER: sqledge  <br>      MSSQL_SA_PASSWORD: &quot;password&quot;<br>      ACCEPT_EULA: &quot;Y&quot;<br>    depends_on:<br>      - sqledge<br>    networks:<br>      sb-emulator:<br>        aliases:<br>          - &quot;sb-emulator&quot;<br>  sqledge:<br>        container_name: &quot;sqledge&quot;<br>        image: &quot;mcr.microsoft.com/azure-sql-edge:latest&quot;<br>        networks:<br>          sb-emulator:<br>            aliases:<br>              - &quot;sqledge&quot;<br>        environment:<br>          ACCEPT_EULA: &quot;Y&quot;<br>          MSSQL_SA_PASSWORD: &quot;password&quot;<br>networks:<br>  sb-emulator:</pre><p>Make sure you have the correct volume mapped and your emulator is able to access the config.json file. To diagnose issues, you can always tail the container logs to see what has happening.</p><p>3. To connect to the service bus emulator, you can always use the following connection string</p><pre>&quot;Endpoint=sb://localhost;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;&quot;</pre><p>If you have different setup or interact with the emulator differently, please check out this link for how to interact with the emulator.</p><p><a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/test-locally-with-service-bus-emulator?tabs=automated-script">Test locally by using the Azure Service Bus emulator - Azure Service Bus</a></p><h3>The Conclusion</h3><p>The Azure Service bus emulator offers a local development experience for the Service Bus service. You can use the emulator to develop and test code against the service in isolation, free from cloud interference. Huray! Huray!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f026a2bc174" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Find out how Event hub emulator helps with local development]]></title>
            <link>https://mrkevin-wang.medium.com/find-out-how-event-hub-emulator-helps-with-local-development-8a5f5a50189d?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a5f5a50189d</guid>
            <category><![CDATA[emulator]]></category>
            <category><![CDATA[event-driven-systems]]></category>
            <category><![CDATA[event-hub]]></category>
            <category><![CDATA[azure-event-hub]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 03:04:44 GMT</pubDate>
            <atom:updated>2025-01-08T03:04:44.219Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://learn.microsoft.com/en-us/azure/event-hubs/overview-emulator">Overview of the Azure Event Hubs emulator - Azure Event Hubs</a></p><p>Microsoft has provided an event hub emulator to help with the following aspects:</p><ul><li>Local development: The emulator provides a local development experience, so you can work offline and avoid network latency.</li><li>Cost efficiency: With the emulator, you can test your applications without incurring any cloud usage costs.</li><li>Isolated testing environment: You can test your code in isolation, to help ensure that other activities in the cloud don’t affect the tests.</li><li>Optimized inner development loop: You can use the emulator to quickly prototype and test your applications before deploying them to the cloud.</li></ul><p>Please be aware there are some limitations, but for most of the scenarios that could be satisfied with this emulator.</p><h3>Using emulator with docker-compose</h3><ol><li>To start the emulator, supply a configuration for the entities that you want to use. Save the following JSON file locally as <em>config.json</em>:</li></ol><pre>{<br>    &quot;UserConfig&quot;: {<br>      &quot;NamespaceConfig&quot;: [<br>        {<br>          &quot;Type&quot;: &quot;EventHub&quot;,<br>          &quot;Name&quot;: &quot;emulatorNs1&quot;,<br>          &quot;Entities&quot;: [<br>            {<br>              &quot;Name&quot;: &quot;pricing-delta&quot;,<br>              &quot;PartitionCount&quot;: &quot;1&quot;,<br>              &quot;ConsumerGroups&quot;: [<br>                {<br>                  &quot;Name&quot;: &quot;consumer-group-1&quot;<br>                },<br>                {<br>                  &quot;Name&quot;: &quot;consumer-group-2&quot;<br>                }<br>              ]<br>            },<br>            {<br>              &quot;Name&quot;: &quot;article-delta&quot;,<br>              &quot;PartitionCount&quot;: &quot;1&quot;,<br>              &quot;ConsumerGroups&quot;: [<br>                {<br>                  &quot;Name&quot;: &quot;consumer-group-2&quot;<br>                }<br>              ]<br>            }<br>          ]<br>        }<br>      ], <br>      &quot;LoggingConfig&quot;: {<br>        &quot;Type&quot;: &quot;File&quot;<br>      }<br>    }<br>  }</pre><p>In the above config file for the emulator, I specified:</p><ul><li>one event-hub namespace</li><li>two event hubs</li><li>three consumer groups</li></ul><p>2. Now we need to create a service using docker-compose to start this event-hub emulator. Azurite will be required for saving &amp; retrieving the checkpoint files.</p><pre>services:<br>  emulator:<br>    container_name: &quot;eventhubs-emulator&quot;<br>    image: &quot;mcr.microsoft.com/azure-messaging/eventhubs-emulator:latest&quot;<br>    volumes:<br>      - &quot;.\\Config.json:/Eventhubs_Emulator/ConfigFiles/Config.json&quot;<br>    ports:<br>      - &quot;5672:5672&quot;<br>    environment:<br>      BLOB_SERVER: azurite<br>      METADATA_SERVER: azurite<br>      ACCEPT_EULA: &#39;Y&#39;<br>    depends_on:<br>      - azurite<br>    networks:<br>      eh-emulator:<br>        aliases:<br>          - &quot;eventhubs-emulator&quot;<br>  azurite:<br>    container_name: &quot;azurite&quot;<br>    image: &quot;mcr.microsoft.com/azure-storage/azurite:latest&quot;<br>    ports:<br>      - &quot;10000:10000&quot;<br>      - &quot;10001:10001&quot;<br>      - &quot;10002:10002&quot;<br>    networks:<br>      eh-emulator:<br>        aliases:<br>          - &quot;azurite&quot;<br>networks:<br>  eh-emulator:</pre><p>Make sure you have the correct volume mapped and your emulator is able to access the config.json file. To diagnose issues, you can always tail the container logs to see what has happening.</p><p>3. Now let’s create a publisher to publish some messages to the event-hub emulator.</p><pre>&quot;Endpoint=sb://localhost;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;&quot;</pre><p>I am using this connection string to interact with the emulator, if you have different setup or interact with the emulator differently, please check out this link for how to interact with the emulator. <a href="https://learn.microsoft.com/en-us/azure/event-hubs/test-locally-with-event-hub-emulator?tabs=docker-linux-container%2Cusing-kafka">https://learn.microsoft.com/en-us/azure/event-hubs/test-locally-with-event-hub-emulator?tabs=docker-linux-container%2Cusing-kafka</a></p><p>Creating the event-hub publisher</p><pre>EventHubProducerClient producerClient = new EventHubProducerClient(_eventHubNamespaceConnectionString, _eventHubName);<br><br>// Create a batch of events <br>using EventDataBatch pricingEventBatch = await producerClient.CreateBatchAsync();<br><br>// Implement this method in your own way<br>var pricingEvents = CreatePricingEvent(storeId);<br><br>for (int i = 0; i &lt; pricingEvents.Length; i++)<br>{<br>    if (!pricingEventBatch.TryAdd(pricingEvents[i]))<br>    {<br>        // if it is too large for the batch<br>        throw new Exception($&quot;Event {i} is too large for the batch and cannot be sent.&quot;);<br>    }<br>}<br><br>try<br>{<br>    // Use the producer client to send the batch of events to the event hub<br>    await producerClient.SendAsync(pricingEventBatch);<br>    Console.WriteLine($&quot;A batch of {pricingEvents.Length} pricing events for store:{storeId} has been published.&quot;);<br>}<br>finally<br>{<br>    await producerClient.DisposeAsync();<br>}</pre><p>4. The last step is to create a consumer app to consume these messages from event-hub emulator. I am just making it simple enough to demonstrate the emulator works.</p><pre>public async Task Recieve()<br>{<br>    var consumer = new EventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName, <br>        _eventHubNamespaceConnectionString, _eventHubName);<br><br>    await foreach (PartitionEvent partitionEvent in consumer.ReadEventsAsync(new ReadEventOptions { MaximumWaitTime = TimeSpan.FromSeconds(2) }))<br>    {<br>        if (partitionEvent.Data != null)<br>        {<br>            string messageBody = Encoding.UTF8.GetString(partitionEvent.Data.Body.ToArray());<br>            Console.WriteLine($&quot;Message received : &#39;{messageBody}&#39;&quot;);<br>        }<br>        else<br>        {<br><br>            break;<br>        }<br>    }<br>}</pre><h3>The Conclusion</h3><p>The Azure Event Hubs emulator offers a local development experience for the Event Hubs service. You can use the emulator to develop and test code against the service in isolation, free from cloud interference. Huray! Huray!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a5f5a50189d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to build a Dapr’s Pluggable Component]]></title>
            <link>https://mrkevin-wang.medium.com/how-to-build-a-daprs-pluggable-component-dcadc0f2df1a?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcadc0f2df1a</guid>
            <category><![CDATA[dapr]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[pluggable-module]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 00:00:43 GMT</pubDate>
            <atom:updated>2025-01-08T00:00:43.015Z</atom:updated>
            <content:encoded><![CDATA[<p>Pluggable components are components that are not included as part the runtime, as opposed to the built-in components included with dapr init. You can configure Dapr to use pluggable components that leverage the building block APIs, but are registered differently from the built-in Dapr components.</p><h3>Pluggable components vs. built-in components</h3><p>Dapr provides two approaches for registering and creating components:</p><ul><li>The built-in components included in the runtime and found in the components-contrib repository .</li><li>Pluggable components which are deployed and registered independently.</li></ul><p>While both registration options leverage Dapr’s building block APIs, each has a different implementation processes.</p><h3>Why Use Pluggable Components?</h3><ul><li><strong>Flexibility</strong>: Dapr provides the flexibility to integrate with different technologies and services without needing to change the core application code. You can plug in your preferred infrastructure components.</li><li><strong>Customizability</strong>: You can tailor the behavior of Dapr to your specific needs by swapping components (e.g., using a different message broker or storage solution).</li><li><strong>Portability</strong>: With pluggable components, Dapr can work across different cloud providers or on-premises infrastructures, ensuring that your microservices are portable.</li><li><strong>Decoupling</strong>: Pluggable components allow for loose coupling between your application and the underlying infrastructure, enabling you to change technologies or systems without impacting the application code.</li></ul><h3>Building my first pluggable component</h3><p>I want to build a demo app which is acting as a dapr state store, which gives you ability to simply create, retrieve and delete records.</p><ol><li>I create <strong>MyStateStore </strong>which will implement <strong>IStateStore </strong>interface from Dapr.</li></ol><pre>    internal sealed class MyStateStore : IStateStore<br>    {<br>        private readonly ILogger&lt;MyStateStore&gt; _logger;<br>        private readonly static IDictionary&lt;string, string?&gt; Storage = new ConcurrentDictionary&lt;string, string?&gt;();<br>        public MyStateStore(ILogger&lt;MyStateStore&gt; logger)<br>        {<br>            _logger = logger;<br>        }<br><br>        public Task DeleteAsync(StateStoreDeleteRequest request, CancellationToken cancellationToken = default)<br>        {<br>            this._logger.LogInformation(&quot;Remove request for key {key}&quot;, request.Key);<br>            Storage.Remove(request.Key);<br>            return Task.FromResult(new SetResponse());<br>        }<br><br>        public Task&lt;StateStoreGetResponse?&gt; GetAsync(StateStoreGetRequest request, CancellationToken cancellationToken = default)<br>        {<br>            this._logger.LogInformation(&quot;Get request for key {key}&quot;, request.Key);<br>            if (Storage.TryGetValue(request.Key, out var data))<br>            {<br>                return Task.FromResult(new StateStoreGetResponse<br>                {<br>                    Data = Encoding.ASCII.GetBytes(data),<br>                });<br>            }<br>            return Task.FromResult(new StateStoreGetResponse { });<br>        }<br><br>        public Task InitAsync(MetadataRequest request, CancellationToken cancellationToken = default)<br>        {<br>            _logger.LogInformation(&quot;Init request for quickstore&quot;);<br>            return Task.FromResult(new InitResponse { });<br>        }<br><br>        public Task SetAsync(StateStoreSetRequest request, CancellationToken cancellationToken = default)<br>        {<br>            this._logger.LogInformation(&quot;Set request for key {key}&quot;, request.Key);<br>            Storage[request.Key] = Encoding.UTF8.GetString(request.Value.Span); <br>            return Task.FromResult(new SetResponse());<br>        }<br>    }</pre><p>2. I want to register MyStateStore as a service, in program.cs</p><pre>using Dapr.PluggableComponents;<br>using quickstore;<br><br>var app = DaprPluggableComponentsApplication.Create();<br><br>app.RegisterService(<br>    &quot;quickstore&quot;,<br>    serviceBuilder =&gt;<br>    {<br>        // Register one or more components with this service.<br>        serviceBuilder.RegisterStateStore&lt;MyStateStore&gt;();<br>    });<br><br>app.Run();</pre><p>3. Create the docker file for this application, so it can be containerized.</p><pre>FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base<br>WORKDIR /app<br><br>FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build<br>WORKDIR /src<br>COPY . ./<br>RUN dotnet restore &quot;./quickstore.csproj&quot;<br><br>RUN dotnet build &quot;./quickstore.csproj&quot; -c Release -o /app/build<br><br>FROM build AS publish<br>RUN dotnet publish &quot;./quickstore.csproj&quot; -c Release -o /app/publish /p:UseAppHost=false<br><br>FROM base AS final<br>WORKDIR /app<br>COPY --from=publish /app/publish .<br>ENTRYPOINT [&quot;dotnet&quot;, &quot;quickstore.dll&quot;]</pre><p>4. You will need to define the state component schema and save as yaml file which we will use later.</p><pre>apiVersion: dapr.io/v1alpha1<br>kind: Component<br>metadata:<br>  name: statestore<br>spec:<br>  type: state.quickstore<br>  version: v1<br>  initTimeout: 1m<br>  metadata:<br>    - name: quickstore</pre><p>5. To test dapr, we need to create a simple dapr-client. I made it simple enough to use DaprClient to save and read dapr states via the “<strong>statestore</strong>” I created.</p><pre>    class Program<br>    {<br>        static async Task Main(string[] args)<br>        {<br>            string DAPR_STORE_NAME = &quot;statestore&quot;;<br>            var clientBuilder = new DaprClientBuilder();<br>            // var port = 50002;<br>            // clientBuilder = clientBuilder.UseGrpcEndpoint($&quot;http://localhost:{port}&quot;);<br>            //clientBuilder = clientBuilder($&quot;http://localhost&quot;);<br><br>            using var client = clientBuilder.Build();<br>            while (true)<br>            {<br>                System.Threading.Thread.Sleep(5000);<br>                Random random = new Random();<br>                int orderId = random.Next(1, 1000);<br>                //Using Dapr SDK to save and get state<br>                await client.SaveStateAsync(DAPR_STORE_NAME, &quot;order_1&quot;, orderId.ToString());<br>                await client.SaveStateAsync(DAPR_STORE_NAME, &quot;order_2&quot;, orderId.ToString());<br>                var result = await client.GetStateAsync&lt;string&gt;(DAPR_STORE_NAME, &quot;order_1&quot;);<br>                Console.WriteLine(&quot;Result after get: &quot; + result);<br>            }<br>        }<br>    }</pre><p>6. To run this dapr client in standalone mode, you can run this command.</p><pre>dapr run --app-id orderprocessing --app-port 6001 --dapr-http-port 3601 --dapr-grpc-port 60001 dotnet run</pre><p>7. Alternatively, you can dockerize it with a docker file, so it can be deployed as docker-compose or kubernetes.</p><pre>FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env<br>WORKDIR /FirstDaprStateClient<br><br># Copy everything<br>COPY . ./<br># Restore as distinct layers<br>RUN dotnet restore<br># Build and publish a release<br>RUN dotnet publish -c Release -o out<br><br># Build runtime image<br>FROM mcr.microsoft.com/dotnet/aspnet:7.0<br>WORKDIR /FirstDaprStateClient<br>COPY --from=build-env /FirstDaprStateClient/out .<br>ENTRYPOINT [&quot;dotnet&quot;, &quot;FirstDaprStateClient.dll&quot;]</pre><p>8. Now let’s test our pluggable component with our dapr client in a docker-compose. We will need to create the following services:</p><ul><li>client application</li><li>dapr</li><li>quickstore (i.e. my testing pluggable component)</li><li>placement</li></ul><pre>version: &#39;3&#39;<br>services:<br>  client:<br>    build:<br>      context: .<br>      dockerfile: FirstDaprStateClient/Dockerfile<br>    ports:<br>      - &quot;50002:50002&quot;<br>    depends_on:<br>      - quickstore<br>      - placement<br>    networks:<br>      - hello-dapr<br>  dapr:<br>    image: &quot;daprio/daprd:edge&quot;<br>    command: [<br>      &quot;./daprd&quot;,<br>      &quot;--app-id&quot;, &quot;client&quot;,<br>      &quot;--app-port&quot;, &quot;3000&quot;,<br>      &quot;--dapr-grpc-port&quot;, &quot;50002&quot;,<br>      &quot;--components-path&quot;, &quot;/components&quot;,<br>      &quot;--placement-host-address&quot;, &quot;placement:50006&quot;, # Dapr&#39;s placement service can be reach via the docker DNS entry<br>      &quot;--log-level&quot;, &quot;debug&quot;,<br>     ]<br>    volumes:<br>        - &quot;./components:/components&quot;<br>        - &quot;/tmp/dapr-components-sockets:/tmp/dapr-components-sockets&quot;<br>    depends_on:<br>      - client<br>      - quickstore<br>    network_mode: &quot;service:client&quot; # Attach the nodeapp-dapr service to the nodeapp network namespace<br><br>  quickstore:<br>    build: <br>      context: quickstore<br>      dockerfile: Dockerfile<br>    volumes:<br>      - &quot;/tmp/dapr-components-sockets:/tmp/dapr-components-sockets&quot;<br>    networks:<br>      - hello-dapr<br><br>  placement:<br>    image: &quot;daprio/dapr&quot;<br>    command: [&quot;./placement&quot;, &quot;--port&quot;, &quot;50006&quot;]<br>    ports:<br>      - &quot;50006:50006&quot;<br>    depends_on:<br>      - quickstore<br>    networks:<br>      - hello-dapr  <br><br>networks:<br>  hello-dapr: null</pre><p>9. When you run docker-compose up, you would see the dapr client is interacting with dapr statestore that we created in the logs.</p><pre>dockcer-compose up</pre><p>10. If you want to run it in kubernetes, I have pre-installed minikube locally to test it.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: firstdaprstateclient<br>  labels:<br>    app: firstdaprstateclient<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: firstdaprstateclient<br>  template:<br>    metadata:<br>      labels:<br>        app: firstdaprstateclient<br>      annotations:<br>        dapr.io/enabled: &quot;true&quot;<br>        dapr.io/app-id: &quot;firstdaprstateclient&quot;<br>        #dapr.io/app-port: &quot;80&quot;<br>        #dapr.io/dapr-grpc-port: &quot;50002&quot;<br>        dapr.io/enable-api-logging: &quot;true&quot;<br>        dapr.io/unix-domain-socket-path: /tmp/dapr-components-sockets<br>        #dapr-unix-domain-socket<br>    spec:<br>      containers:<br>      - name: consumer-app<br>        image: superwalnut/dapr-client-demo:latest<br>        volumeMounts:<br>        - name: dapr-unix-domain-socket<br>          mountPath: /tmp/dapr-components-sockets<br>        ports:<br>        - containerPort: 80<br>        imagePullPolicy: Always      <br><br>      - name: quickstore<br>        image: superwalnut/dapr-component:latest<br>        command: [&quot;dotnet&quot;, &quot;quickstore.dll&quot;]<br>        env:<br>          - name: DAPR_GRPC_PORT<br>            value: &quot;50001&quot;<br>          - name: DAPR_HTTP_PORT<br>            value: &quot;3500&quot;<br>        ports:<br>          - containerPort: 50001<br>          - containerPort: 3500<br>        volumeMounts:<br>          - name: dapr-unix-domain-socket<br>            mountPath: /tmp/dapr-components-sockets<br>      volumes:<br>      - name: dapr-unix-domain-socket<br>        emptyDir: {}</pre><p>With Dapr’s pluggable components allow developers to easily customize how their microservices interact with external systems, providing flexibility, portability, and ease of integration with various cloud-native services.</p><p>These components are an essential part of Dapr’s modular design and help developers choose the right technologies for their applications while abstracting away much of the complexity involved in integrating with those systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcadc0f2df1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Discover Dapr’s ability for event driven systems]]></title>
            <link>https://mrkevin-wang.medium.com/discover-daprs-ability-for-event-driven-systems-0761dfbfa958?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/0761dfbfa958</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[dapr]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Tue, 07 Jan 2025 07:10:18 GMT</pubDate>
            <atom:updated>2025-01-07T07:10:18.458Z</atom:updated>
            <content:encoded><![CDATA[<p>Dapr (Distributed Application Runtime) is an open-source, event-driven, portable runtime that provides building blocks for building resilient, scalable, and distributed applications.</p><h3>Prerequisites</h3><ul><li>minikube</li><li>Dapr systems: dapr init — kubernetes</li><li>Redis: minikube pod</li><li>MongoDB: minikube pod</li><li>Deploy dapr component</li><li>Demo Article API (.net)</li></ul><h3>Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bSPupN5VaLA5pRpB" /></figure><h3>Knowledge Structure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bqhSmYC8eMo2nFhv" /></figure><h3>Business Benefits</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/0*AV1ltbCWspg2zdIg.jpg" /></figure><ul><li>Focus on Business Logic and accelerated development with less cost.</li><li>Enables incremental modernization of applications without disruptions, leveraging existing investments.</li><li>Provide flexibility and agility to switch infrastructure design and implementation.</li><li>Cloud and platform independence.</li><li>Open-source and community support.</li><li>Free to use.</li></ul><h3>Engineering Benefits</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*21sVuuuz6W3FCaAt" /></figure><ul><li>Prebuild component to solve common problem.</li><li>Consistent integration experience.</li><li>Loosely couples microservices for a more resilient architecture.</li><li>Customize component to provide extensibility.</li><li>Provide infrastructure mockability for the integration tests.</li></ul><h3>Key Concepts</h3><ul><li>Sidecar</li><li>Component</li><li>Component Schema</li><li>Building Blocks</li></ul><h3>Sidecar</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/0*pRgffLIud_r50m0l" /></figure><ul><li>Sidecar is the basic element of Dapr system.</li><li>A Dapr sidecar is either a process or a container that runs alongside a primary application to provide additional functionality or services.</li><li>Each application instance has its own unique Dapr sidecar.</li><li>Dapr sidecar is named as “<strong>daprd</strong>”.</li><li>In K8S, Dapr sidecar is a container running alongside with the app hosted in the same pod.</li><li>The Dapr sidecar can communicate with different downstream targets, including Dapr components, Dapr actors or other Dapr sidecars.</li><li>Different building blocks will require the Dapr sidecar to communicate with different targets through various ways. e.g HTTP, gRPC or MQTT.</li><li>Dapr sidecar, as the application’s agent, is responsible for handling the integration related to the downstream targets.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i00ocm9SApEKPxQK" /></figure><h3>Component</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MWCkz8PT94At4FG2" /></figure><ul><li>Dapr uses a modular design where functionality is delivered as a component.</li><li>Dapr components provide specific functionalities that you can leverage.</li><li>By abstracting away the underlying implementation details, Dapr component provides a consistent interface for interacting with different services, regardless of the specific technology or provider used.</li><li>Pluggable component is available for Dapr. Engineer team can implement its own component with more customized functions.</li></ul><h3>Component Schema</h3><ul><li>Components must be registered before use, which involves defining them in a YAML file using a component schema.</li><li>The section <strong>spec.type </strong>will define the component type. The pattern of this value is <strong>[category].[implementation]</strong></li></ul><p><strong>example: state — </strong>mongo component schema</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/0*aOCKUDY0neeNtOHo" /></figure><p><strong>example</strong>: state — redist component schema</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/0*4Yxp_PsQ7oMPmQyw" /></figure><p>example: pub-sub component schema</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/0*twFXMPyaBm_HFmxy" /></figure><h3>Building Blocks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*LFMzuL4WAzrdgc2G" /></figure><ul><li>HTTP or gRPC API.</li><li>Simplify challenges in microservices.</li><li>Provide consistent API.</li><li>Abstract away the implementation details.</li><li>Dapr provides various of building blocks.</li><li>Extensible.</li></ul><p>I am going to show you what can you do with some of the popular building blocks.</p><h4>State Management</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qBDQmzLuV5Sy3GpH" /></figure><ul><li>State Store Abstraction.</li><li>State Management API.</li><li>State Store Configuration.</li><li>Dapr supports a wide range of state stores: Redis, Cosmos DB, SQL Database, MongoDB, DynamoDB, Cassandra, etc.<br><a href="https://github.com/dapr/components-contrib/tree/master/state">https://github.com/dapr/components-contrib/tree/master/state</a></li></ul><h4>Pub/Sub Messaging</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9u5Bt8uVddhvvtwZ" /></figure><ul><li>Publisher API.</li><li>Subscriber API.</li><li>Supports multiple messaging systems, such as Azure Service Bus, RabbitMQ, Kafka, NATS, and more.<br>https://github.com/dapr/components-contrib/tree/master/pubsub</li><li>Retry and Error Handling.</li></ul><h4>Service Invocation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hV1NT7bb0RN7XPY2" /></figure><ul><li>Service-to-Service Invocation: Dapr enables services to invoke methods or APIs of other services using a simple and consistent programming model.</li><li>Pluggable Communication Protocols: Dapr supports various communication protocols, including HTTP, gRPC.</li><li>Request-Response and Fire-and-Forget Patterns: Dapr supports both request-response and fire-and-forget communication patterns.</li><li>Circuit Breaker and Retries: Dapr includes built-in circuit breaker and retry mechanisms to handle transient failures during service invocations.</li></ul><h3>Sidecar &amp; Component Lifecycle</h3><h4>Dapr Control Plane</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*iVK06x-jvYnL-YPxqfnjcg.png" /></figure><ul><li>The Dapr Control Plane is a collection of services that handle the management and configuration of the Dapr runtime.</li><li>Four major services<br>- Sidecar injector service<br>- Operator service<br>- Placement service<br>- Sentry service</li></ul><p>How it looks in kubernetes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oR2jU0pcBFCwsYll" /></figure><h4>Register Components</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hckOLlyvUvlqVw63" /></figure><ul><li>Component yaml files can be applied via kubectl or helm.</li><li>Dapr operator service will consume component yaml file and register component schemas as k8s custom resource definitions.</li><li>Any update and delete of Dapr component schemas are also handled by the operator service.</li></ul><h4>Inject Sidecar</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EzBFlRdxI5FflgcA" /></figure><ul><li>Enable Dapr in app deployment using Dapr Kubernetes annotation.</li><li>Sidecar injector consumes the app deployment file to inject the Dapr sidecar container to the k8s pod.</li><li>Dapr sidecar performs readiness checks during initialization and connection establishment to make sure it is ready to go.</li><li>In specific use cases like pub-sub , Dapr sidecar waits for the app launch to ensure communication established.</li></ul><h4>Message Journey</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jJJiMUrClX7tRuS6" /></figure><ul><li>The Dapr sidecar exposes APIs via HTTP or gRPC that applications can use to communicate with it.</li><li>Rather than directly integrating with infrastructure resources, Dapr communicates with Dapr components as an intermediary.</li><li>Components are responsible for integrating with the underlying infrastructure resources.</li><li>The application can have active or passive communication with the sidecar depending on the nature of the component type.</li><li>In active communication, the application interacts directly with the Dapr sidecar, which forwards requests to the Dapr runtime and returns the response.</li><li>In passive communication, the application hosts a client side API using the Dapr SDK. The sidecar intercepts and processes messages sent to the application through this API, performing Dapr operations and delivering the processed message.</li></ul><h4>Sidecar Health</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ySF3Hg0n5sr8nrZd" /></figure><ul><li>The sidecar has been injected successfully but has internal during initialization.</li><li>Sidecar provide liveness and readiness health check to K8S.</li><li>Failing liveness probe will restart the container, whereas failing readiness probe will stop our application from serving traffic.</li><li>However, sidecar can also failed to inject.</li><li>The sidecar may fail to inject due to the following reasons:<br>- The k8s cluster crashed, and the app pod was launched before the injector service started.<br>- Transient failures occurred within the Injector service.</li><li>To address this issue, the operator service has introduced an <strong>injector watchdog </strong>function, which ensures that the sidecar always exists with the app in the pod.</li><li>Please note that the injector watchdog function <strong>is disabled by default.</strong></li></ul><h3>Demo</h3><p>I want to create an API to interact with Dapr’s state in Kubernetes environment. Here is what I try to do:</p><ol><li>Create an demo API with endpoint</li></ol><pre>    app.MapGet(&quot;/articles/{articleId}&quot;, async (string articleId, IArticleRepository articleRepository) =&gt;<br>            await articleRepository.GetArticle(articleId))<br>        .WithName(&quot;Get Article By Id&quot;);</pre><p>2. In the API, you will need <strong>DaprClientBuilder </strong>to query dapr’s states</p><pre>        using var client = new DaprClientBuilder().Build();<br>        var queryBuilder = new DaprStateQueryBuilder()<br>            .Filter(new EqFilterExpression(&quot;category&quot;, category));<br>        var metadata = new Dictionary&lt;string, string&gt; {<br>            { &quot;contentType&quot;, &quot;application/json&quot; },<br>            { &quot;queryIndexName&quot;, &quot;articleCategoryIndex&quot; }<br>        };<br>        var result = await client.QueryStateAsync&lt;Models.Article&gt;(_stateStoreName, queryBuilder.Build(), metadata: metadata);<br>        return result.Results.Select(q =&gt; q.Data).ToList();</pre><p>3. To test dapr locally on your computer, you will need to install <strong>minikube</strong></p><p>4. Create kubernetes namespace: kube-env-setup.yaml</p><pre>apiVersion: v1<br>kind: Namespace<br>metadata:<br>  name: apps</pre><p>and apply by using <strong>kubectl</strong></p><pre>kubectl apply -f ../kube-env-setup.yaml</pre><p>5. initialise dapr to the kubernetes</p><pre>dapr init --kubernetes --wait<br><br>kubectl get service -n dapr-system</pre><p>6. Create redis deployment file</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: redis-db<br>  namespace: apps<br>  labels:<br>    app: redis<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: redis<br>  template:<br>    metadata:<br>      labels:<br>        app: redis<br>    spec:<br>      containers:<br>        - name: redis<br>          image: redis/redis-stack:latest<br>          ports:<br>            - containerPort: 6379<br>          volumeMounts:<br>            - name: redis-data<br>              mountPath: /data<br>      volumes:<br>        - name: redis-data<br>          persistentVolumeClaim:<br>            claimName: redis-pvc<br><br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: redis-db<br>  namespace: apps<br>spec:<br>  selector:<br>    app: redis<br>  ports:<br>    - name: redis<br>      protocol: TCP<br>      port: 6379<br>      targetPort: 6379<br>  type: NodePort<br><br>---<br>kind: PersistentVolumeClaim<br>apiVersion: v1<br>metadata:<br>  name: redis-pvc<br>  namespace: apps<br>spec:<br>  accessModes:<br>    - ReadWriteOnce<br>  storageClassName: standard<br>  resources:<br>    requests:<br>      storage: 1Gi</pre><p>7. Create mongo deployment file</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: mongodb<br>  namespace: apps<br>  labels:<br>    app: mongodb<br>spec:<br>  selector:<br>    matchLabels:<br>      app: mongodb<br>  replicas: 1<br>  template:<br>    metadata:<br>      labels:<br>        app: mongodb<br>    spec:<br>      containers:<br>      - name: mongodb<br>        image: mongo:latest<br>        env:<br>        - name: MONGO_INITDB_ROOT_USERNAME<br>          value: root<br>        - name: MONGO_INITDB_ROOT_PASSWORD<br>          value: password<br>        ports:<br>        - containerPort: 27017<br>        volumeMounts:<br>        - name: mongodb-data<br>          mountPath: /data/db<br>      volumes:<br>      - name: mongodb-data<br>        persistentVolumeClaim:<br>          claimName: mongodb-pvc<br><br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: mongodb<br>  namespace: apps<br>spec:<br>  selector:<br>    app: mongodb<br>  ports:<br>    - name: mongodb<br>      protocol: TCP<br>      port: 27017<br>      targetPort: 27017<br>  type: NodePort<br><br>---<br>kind: PersistentVolumeClaim<br>apiVersion: v1<br>metadata:<br>  name: mongodb-pvc<br>  namespace: apps<br>spec:<br>  accessModes:<br>    - ReadWriteOnce<br>  storageClassName: standard<br>  resources:<br>    requests:<br>      storage: 1Gi</pre><p>8. apply these files to kubernetes</p><pre>kubectl apply -f ../redis-db.yaml<br><br>kubectl apply -f ../mongo-db.yaml</pre><p>9. Now specify the component state using redis: <strong>dapr-component-state-redis.yaml</strong></p><pre>apiVersion: dapr.io/v1alpha1<br>kind: Component<br>metadata:<br>  name: demostore<br>  namespace: apps<br>spec:<br>  version: v1<br>  type: state.redis<br>  metadata:<br>  - name: redisHost<br>    value: redis-db:6379<br>  - name: queryIndexes<br>    value: |<br>      [<br>        {<br>          &quot;name&quot;: &quot;articleCategoryIndex&quot;,<br>          &quot;indexes&quot;: [<br>            {<br>              &quot;key&quot;: &quot;category&quot;,<br>              &quot;type&quot;: &quot;TEXT&quot;<br>            }<br>          ]<br>        }<br>      ]</pre><p>10. Once you have applied this resource to kubernetes, dapr will be using redis to manipulate states.</p><pre>kubectl apply -f ../dapr-component-state-redis.yaml</pre><p>11. Once you have done above steps, Dapr is ready and running. Now define the API deployment file and apply to kubernetes: <strong>article-api.yaml</strong></p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: article-api<br>  namespace: apps<br>  labels:<br>    app: article-api<br>spec:<br>  type: NodePort<br>  ports:<br>  - port: 8080<br>    targetPort: 80<br>  selector:<br>    app: article-api<br><br><br>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name:  article-api<br>  namespace: apps<br>  labels:<br>    app: article-api<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: article-api<br>  template:<br>    metadata:<br>      labels:<br>        app: article-api<br>      annotations:<br>        dapr.io/enabled: &quot;true&quot;<br>        dapr.io/app-id: &quot;article-api&quot;<br>        dapr.io/app-port: &quot;80&quot;<br>        dapr.io/enable-api-logging: &quot;true&quot;<br>    spec:<br>      containers:<br>      - name: article-api<br>        image: automatefse/dapr-demo-single-state:latest<br>        ports:<br>        - containerPort: 80<br>        imagePullPolicy: Always</pre><p>12. Apply this to kubernetes, please note you might need to port forward to get API working.</p><pre>kubectl apply -f ../article-api.yaml<br><br>kubectl port-forward service/article-api 8080:8080 -n apps</pre><p>13. Try to create another state component for using mongoDB under the hood, i.e. <strong>dapr-component-state-mongo.yaml</strong></p><pre>apiVersion: dapr.io/v1alpha1<br>kind: Component<br>metadata:<br>  name: demostore<br>  namespace: apps<br>spec:<br>  version: v1<br>  type: state.mongodb<br>  metadata:<br>  - name: host<br>    value: &quot;mongodb&quot;<br>  - name: port<br>    value: &quot;27017&quot;  <br>  - name: username<br>    value: &quot;root&quot;<br>  - name: password<br>    value: &quot;password&quot;<br>  - name: databaseName<br>    value: &quot;testdb&quot;<br>  - name: collectionName<br>    value: &quot;articles&quot;<br>  - name: operationTimeout<br>    value: &quot;60s&quot;<br>  - name: params<br>    value: &quot;?authSource=admin&quot;</pre><p>14. Now if you apply this resource to kubernetes, Dapr will be replacing state management from redis to mongoDB.</p><pre>kubectl apply -f ../dapr-component-state-azure-cosmos.yaml</pre><p>I hope this gives you some ideas about Dapr and help you kick off your new projects with dapr :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0761dfbfa958" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Github actions to automate CI/CD and deploy angular 11 apps to firebase]]></title>
            <link>https://mrkevin-wang.medium.com/using-github-actions-to-automate-ci-cd-and-deploy-angular-11-apps-to-firebase-ae5a4ceffb0f?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae5a4ceffb0f</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[firebase]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Sat, 13 Mar 2021 06:19:08 GMT</pubDate>
            <atom:updated>2021-03-13T06:49:47.513Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9dw_G7wDW3A4o9MGdwjiEA.jpeg" /></figure><p>If you have built an angular app, where would you deploy it? I have tried a number of cloud providers which you can achieve the same results, such as aws lambda, azure web app, netlify and google firebase, etc. I am writing a series of articles to demonstrate how to deploy in all of these providers. Today I am showing you how to build an angular app and deploy to google firebase.</p><h3><strong>Part 1. Prerequisite</strong></h3><h4><strong>Setup </strong><a href="https://nodejs.org/en/download/"><strong>node.js</strong></a><strong> environment and install angular cli.</strong></h4><pre>npm install -g @angular/cli</pre><h4><strong>Create an angular app if you haven’t built one</strong></h4><pre>ng new test-app</pre><p>run ng serve to test it locally, once your app has no error and runs successfully, let’s go and publish it to firebase.</p><h3><strong>Part 2. Setup firebase</strong></h3><p>Firstly, of course you need to create a firebase account and a firebase project in [firebase console](https://console.firebase.google.com/).</p><p>Then install the firebase tools.</p><pre>npm install -g firebase-tools</pre><p>Login in to firebase using its cli</p><pre>firebase login</pre><p>That allows you use firebase cli to initialize a firebase project.</p><pre>firebase init</pre><p>You will see a few options that you can use your space bar to select features and hit enter to continue</p><pre>Database: Deploy Firebase Real-time Database Rules</pre><pre>Firestore: Deploy rules and create indexes for Firestore</pre><pre>Functions: Configure and deploy Cloud Functions</pre><pre>Hosting: Configure and deploy Firebase Hosting sites</pre><pre>Storage: Deploy Cloud Storage security rules</pre><p>We are only using hosting, select it and hit enter. Firebase CLI will ask you a few questions, they are all pretty straight forward.</p><blockquote>I want to mention this question, Configure as a single-page app (rewrite all URLs to /index.html)? (y/N), as most of angular apps are created as Single page app, so I would choose yes. Of course if you have different routing strategies, it might be a different selection for you.</blockquote><h4><strong>Setup github actions</strong></h4><p>Also it provides an option if you want it to create a github action file for you automatically, how sweet is that, save us plenty of time.</p><pre>Set up automatic builds and deploys with GitHub?</pre><p>select yes and let it does the rest of the job. In the end it will open a link and ask you authorize firebase cli access. The link looks similar to</p><pre><a href="https://github.com/login/oauth/authorize?client_id=xxxxxxxxxx&amp;state=xxxxxx&amp;redirect_uri=http%3A%2F%2Flocalhost%3A9005&amp;scope=read%3Auser%20repo%20public_repo">https://github.com/login/oauth/authorize?client_id=xxxxxxxxxx&amp;state=xxxxxx&amp;redirect_uri=http%3A%2F%2Flocalhost%3A9005&amp;scope=read%3Auser%20repo%20public_repo</a></pre><p>Once that is completed, it creates workflows yml file for github actions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78e54766897d46b53fd333c9d68e98e6/href">https://medium.com/media/78e54766897d46b53fd333c9d68e98e6/href</a></iframe><p>All you need to do is to create the actions secret FIREBASE_SERVICE_ACCOUNT_GITHUB_TEST_APP and update it with the firebase-hosting service account ID (grab it from firebase <a href="https://console.cloud.google.com/projectselector2/iam-admin/serviceaccounts">service account</a>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kx78qSJuSXfrz9PK96OQnw.png" /></figure><h3><strong>Part 3. Miscellaneous</strong></h3><h4><strong>Fix output folder</strong></h4><p>The firebase cli generates a firebase.json to provide instructions of deployment. You may notice it sets public folder to be public, so when we build the angular app, we need to build into public folder (instead of default dist folder).</p><p>I am updating the npm build command of package.json to</p><pre>ng build — prod — output-path=public</pre><h4><strong>Manual deploy</strong></h4><p>You can also manual deploy it via firebase cli, by running</p><pre>firebase deploy</pre><h3><strong>Part 4. Finally</strong></h3><p>If you find my article is helpful, please click <strong>Applaud</strong> to support me.</p><p>Here is the link to GitHub to grab the complete source code for the app.</p><p><a href="https://github.com/superwalnut/github-actions-angular-firebase-sample">superwalnut/github-actions-angular-firebase-sample</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae5a4ceffb0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Convert markdown code blocks to gist embeded code for multiple blogging platforms]]></title>
            <link>https://mrkevin-wang.medium.com/convert-markdown-code-blocks-to-gist-embeded-code-for-multiple-blogging-platforms-24dfad048fda?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/24dfad048fda</guid>
            <category><![CDATA[gist]]></category>
            <category><![CDATA[markdown]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[tech-blog]]></category>
            <category><![CDATA[médium]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Sun, 25 Oct 2020 05:53:24 GMT</pubDate>
            <atom:updated>2020-10-25T05:58:32.623Z</atom:updated>
            <content:encoded><![CDATA[<h3>Create a markdown blog post and automatically converted code blocks to gist for publishing in Medium</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eDxsX5NKzFfQ5vgA4t5bXg.png" /></figure><p>I started blogging with medium a while ago and I find their code block format is not ideal. After a few searches and clicks in google, I soon find out tech blogs are using gist as a great tool to embed code blocks into medium blog post. Then I started using it as well, it formats code, highlight keywords, has line numbers and a horizontal scroll bar if the line of code is too long. This is super cool for a tech guy like me, I enjoyed it so much.</p><p>The steps that I have to do is, copy &amp; paste my code into gist and save that as a file in gist.</p><p>Now that this is done, all you need to do is copy the link to your gist and embed it in medium using the embed link option.</p><p>The medium gives you a nicely formatted code blocks. Hooray!</p><p>The only hassle is if you have multiple code blocks in one single post, you have to repeat the same steps over and over again and also don’t get confused which code block goes where.</p><p>So I have been thinking how to reduce the repetition and make writing blog post more efficiently. Here is what I did,</p><p>I write my blogs in markdown (because I always try to keep my post independently to any platform or blog engines) and create a tool to convert code blocks to gist links that can be shared to medium.</p><p>The tool is called <a href="https://www.nuget.org/packages/MD-Gist/">MD-Gist</a>, it can be found in nuget.org</p><p>It does two things (well actually more than just two things, I will write more blogs about other features later on):</p><p>First it scans your post, and discovers all the code blocks within the back-tick blocks.</p><p>Then it creates a gist file with the code block and replace the code with a gist url.</p><p>Finally, you can import your post (in markdown format) to medium without any hassle. Medium allows writers to import post via a url. as I am keeping my posts in Github repository and I can just copy and paste that file’s (e.g. ***.md) url to medium and click “import”.</p><p>If you have <strong>Integration tokens</strong> setup in medium, you can also use the <a href="https://www.nuget.org/packages/MD-Gist/">MD-Gist</a> tool to import as well.</p><p>Or even better to create a git action, once you pushed your post to your Github repository, the git action will automatically convert your code blocks with gist links and import to medium.</p><p>How cool is that!</p><p>I am going to show you all of it.</p><h4>Install <a href="https://www.nuget.org/packages/MD-Gist/">MD-Gist</a></h4><ul><li>Using dotnet tool install --global MD-Gist to install the console tool from nuget</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/149800474a97bf99bbd3301d448ee3c6/href">https://medium.com/media/149800474a97bf99bbd3301d448ee3c6/href</a></iframe><p>Just type md-gist in your terminal and if it is successfully installed, it should show you the help docs.</p><h4>Create Github access token</h4><p>Because we need to access gist to create files, so I go to <a href="https://github.com/settings/tokens/new">Github Create Access Token</a> to create a new token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*8Svt3TTVGPn9EuR8TxmEiA.png" /></figure><p>And make sure you select the Gist scope.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*iWJWa0S1W5Ue2BX7VXM_zQ.png" /></figure><h4>Convert code blocks to gist and import to medium</h4><p>I have to get my blog post markdown file ready to be converted, e.g. I have a blog post called <strong>my-blog-post.md</strong></p><p>Then let’s use <a href="https://www.nuget.org/packages/MD-Gist/">MD-Gist</a> to convert the code blocks by entering the command</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a69f5739c37496b893d66d25d33d507a/href">https://medium.com/media/a69f5739c37496b893d66d25d33d507a/href</a></iframe><p>The &lt;Path&gt; parameter can be a folder or a file, if it is a folder, <a href="https://www.nuget.org/packages/MD-Gist/">MD-Gist</a> will try to convert all the .md files in it.</p><p>Also you are required to enter the &lt;Github_Auth_Token&gt; you just created in the previous step, that allows <a href="https://www.nuget.org/packages/MD-Gist/">MD-Gist</a> to access gist and do the conversion job.</p><p>If the command successfully run, you would see a number of generated .md files. e.g.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f498e0c399bd624ff6a21b8e35642752/href">https://medium.com/media/f498e0c399bd624ff6a21b8e35642752/href</a></iframe><p>Sorry I didn’t mention it works for other blog engines as well, I mean they all have different formats to embed gist links (e.g. hugo blog is using something like{{&lt; gist username b92assadasdb5e583110c28d3cf34d08 &gt;}}). But for medium, it is just purely a link, and meidum will do the rest while importing.</p><p>And <strong>my-blog-post-[Medium].md</strong> is your candidate to import to medium. Of course you have to push your post online that medium can access it. (I pushed my post to a Github repository and get the shareable link, you can also use gist to save your post online.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IdaPP5LlT0g54hSGtFFD8g.png" /></figure><h4>Import to medium via command <a href="https://www.nuget.org/packages/MD-Gist/">MD-Gist</a></h4><p>First you need to create medium integration token in <a href="https://medium.com/me/settings">account settings</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*d5O038Mqbvh288gS1-EUFw.png" /></figure><p>Then enter the command</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/077720fb03c9df92b6a7c9044f3b63de/href">https://medium.com/media/077720fb03c9df92b6a7c9044f3b63de/href</a></iframe><p>Please target the &lt;Files Path&gt; with generated my-blog-post-[Medium].md for best outcome.</p><h4>Automate conversion using Github action</h4><p>This Github action that will automatically detect any .md files and convert the code blocks to gist embedded code and pushed these new files to the repository as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/440680f0fd572fc7b253aae008266b31/href">https://medium.com/media/440680f0fd572fc7b253aae008266b31/href</a></iframe><p>It will create these files that you can publish directly in these blogging platforms</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8826a338d258fd6ec10960c6fbd15ae2/href">https://medium.com/media/8826a338d258fd6ec10960c6fbd15ae2/href</a></iframe><h4>Finally</h4><p>If you find my article is helpful, please click <strong>Applaud</strong> to support me.</p><p>Here is the link to GitHub to grab the complete source code for the app.</p><p><a href="https://github.com/superwalnut/markdown-gist-transform">superwalnut/markdown-gist-transform</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24dfad048fda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a dotnet core Cosnole app template with autofac dependency injections]]></title>
            <link>https://mrkevin-wang.medium.com/create-a-dotnet-core-cosnole-app-template-with-autofac-dependency-injections-60e09f27df17?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/60e09f27df17</guid>
            <category><![CDATA[dependency-injection]]></category>
            <category><![CDATA[autofac]]></category>
            <category><![CDATA[project-template]]></category>
            <category><![CDATA[nuget]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Sat, 12 Sep 2020 10:37:04 GMT</pubDate>
            <atom:updated>2020-09-12T10:37:04.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XkN2miCTZ-A6oYmGlVZgEg.jpeg" /><figcaption>dotnet core console app with autofac</figcaption></figure><p>Every time I create a new project, I have to go through exactly same steps to setup some open source libraries that I always use for any projects.</p><p>For example I often use autofac as my dependency inject container and register a bunch of services and preconfigure them the same way, such as Serilog, Automapper, etc.</p><p>There is nothing difficult to setup all these libraries, it is just time consuming and repetitive job that has to be done every single time.</p><p>So here I create this small template project that is pre-installed and pre-configured with all these libraries, to speed up your development process.</p><h3>Install and use the template</h3><p>This is the link to the published <a href="https://www.nuget.org/packages/Superwalnut.NetCoreConsoleTemplate/">nuget</a> package as a dotnet template,</p><figure><a href="https://www.nuget.org/packages/Superwalnut.NetCoreConsoleTemplate/"><img alt="" src="https://cdn-images-1.medium.com/max/444/0*snw8NEFMOZhOkOml" /></a></figure><p>You can install this template via nuget using dotnet new -i,</p><pre>dotnet new --install Superwalnut.NetCoreConsoleTemplate</pre><p>The template will be installed as core-console-autofac.</p><p>Then you can create your new project using this template,</p><pre>dotnet new core-console-autofac -n MyFirstConsole</pre><h3>What is included in your new project</h3><pre>---- Models <br>      |---- Foo.cs <br>---- Modules <br>      |---- ConsoleModules.cs <br>---- AutoMapper <br>      |---- MyAutoMapperProfile.cs <br>---- appsettings.json <br>---- Program.cs <br>---- Startup.cs </pre><h3>Autofac</h3><p>I created a Startup.cs file to create autofac ContainerBuilder and register all the services using ConfigureServices() method. To keep service registrations neat and clean, I created an autofac module, for the services only consumed by the console app.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f269182f4cec9fd835eb9af2bf65cb01/href">https://medium.com/media/f269182f4cec9fd835eb9af2bf65cb01/href</a></iframe><h3>appsettings.json</h3><p>I need to use ConfigurationBuilder(), to read the physical app setting json file from its environment, and then AddEnvironmentVariables(), so we can override configurations via environment variables.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92c040f6d94cf8e051b54fde9b4db8dc/href">https://medium.com/media/92c040f6d94cf8e051b54fde9b4db8dc/href</a></iframe><h3>Serilog</h3><p>Registered the logger in ConfigureService(),</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95074ff21b5f1ab982cc02fd7db9b622/href">https://medium.com/media/95074ff21b5f1ab982cc02fd7db9b622/href</a></iframe><p>and configured with Console output sinks.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/980f4f6193d59ec7cd94529f9e39d06b/href">https://medium.com/media/980f4f6193d59ec7cd94529f9e39d06b/href</a></iframe><h3>AutoMapper</h3><p>Created a default automapper profile with an example CreateMap().</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae4e9106422c9f5dc25b7962da6b1902/href">https://medium.com/media/ae4e9106422c9f5dc25b7962da6b1902/href</a></iframe><h3>Finally,</h3><p>Congratulations on setup your .net core console app with this template. If you find my article is helpful and saving you some time, please follow me at <a href="https://medium.com/@mrkevin.wang">Medium</a> and share this post with your mates.</p><p>Here is a link to github to grab the full source code.</p><p><a href="https://github.com/superwalnut/dotnet-console-app-template">superwalnut/dotnet-console-app-template</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60e09f27df17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Nuget package triage for your .net solutions & integrated to CI/CD pipelines]]></title>
            <link>https://mrkevin-wang.medium.com/nuget-package-triage-for-your-net-solutions-integrated-to-ci-cd-pipelines-d1bf3e7ccfa5?source=rss-661d1808be74------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1bf3e7ccfa5</guid>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[nuget]]></category>
            <dc:creator><![CDATA[Solopreneur]]></dc:creator>
            <pubDate>Sat, 05 Sep 2020 10:33:16 GMT</pubDate>
            <atom:updated>2020-09-10T05:11:05.986Z</atom:updated>
            <content:encoded><![CDATA[<h3>Nuget package triage for your .net solutions &amp; integrated to CI/CD pipelines</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qV9denOb2jveUVBZ" /><figcaption>Photo by <a href="https://unsplash.com/@alvarordesign?utm_source=medium&amp;utm_medium=referral">Alvaro Reyes</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Do you often work on a .net solution with many projects?</p><p>Do you ever find Newtonsoft.Json is installed with different versions across the whole solution?</p><p>And do you find some nuget packages are 5 years old that never have been updated or even been no longer maintained and unpublished?</p><p>Or find your projects/solutions are using pre-released packages that are not very reliable for production usage?</p><p>I have been struggling with these stuff during most of my projects. It is not a difficult task to fix them up, but it definitely requires some sort of trigger to examine the above scenarios regularly from time to time.</p><p>So I am wondering if I can make it part of the CI/CD process, regularly perform checks against consumed nuget packages, for solutions/projects. With nuget.org’s public API and I chuck in some dotnet core to build a little console app to achieve sanity triage of all these installed nuget dependencies. And it works out really well for me.</p><h3>Here it comes NuSight</h3><p><a href="https://github.com/superwalnut/NuSight">NuSight</a> is tiny .net core console app I built to help your triage your .net solutions for the nuget packages. It is open source and you can find the source code from <a href="https://github.com/superwalnut/NuSight">github</a>. Also it has been published to <a href="https://www.nuget.org/packages/NuSight">nuget.org</a> as a dotnet tool</p><p><a href="https://www.nuget.org/packages/NuSight">NuSight 1.2.2</a></p><p>To install it and use it, you need dotnet CLI and run this command,</p><pre>dotnet tool install --global NuSight</pre><p>After successfully installed, just run nusight you should be able to all its available commands with parameters.</p><pre>Available commands are:</pre><pre>list        - List nuget packages from selected solution &amp; highlight the outdated packages<br>    import      - Import nuget package references of selected project.<br>    export      - Export nuget package references of selected project.<br>    remove      - remove specified nuget packages from selected solution.<br>    list        - List nuget packages from selected solution &amp; highlight the outdated packages<br>    clone       - copy nuget packages from selected solution &amp; install to the target project.</pre><pre>help &lt;name&gt; - For help with one of the above commands<br></pre><h3>How to use NuSight</h3><h4><strong>list command</strong></h4><p>can be used for your CI build to validate your nuget packages for the whole solution.</p><p>— help or -h to list all parameters and descriptions</p><pre>$ nusight list -h</pre><p>— solution or -s to specify the selected solution path, if you haven’t specified any solution path, it will take current directory as selected path</p><pre>$ nusight list -s=&lt;YOUR_PATH&gt;</pre><p>— inconsistency or -i to triage inconsistent nuget package versions installed in the selected solution</p><pre>$ nusight list -s=&lt;YOUR_PATH&gt; -i</pre><p>— outdated or -o to triage outdated nuget packages installed in the selected solution</p><pre>$ nusight list -s=&lt;YOUR_PATH&gt; -o</pre><p>— prereleased or -p to triage if any pre-released packages are installed in the selected solution</p><pre>$ nusight list -s=&lt;YOUR_PATH&gt; -p</pre><p>— unpublished or -u to triage if any unpublished packages are installed in the selected solution.</p><pre>$ nusight list -s=&lt;YOUR_PATH&gt; -u</pre><p>To use them all together, you can do</p><pre>$ nusight list -s=&lt;YOUR_PATH&gt; -i -o -p -u</pre><p>If the triage finds any above errors, it will return with an error code, and your pipeline will fail. Otherwise return with a 0 code and pipeline will succeed.</p><h4>Use it with github actions</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38625db800b41e53be4a83bf5cd56283/href">https://medium.com/media/38625db800b41e53be4a83bf5cd56283/href</a></iframe><h4>Use it with gitlab CI configuration</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d4bf30cb7a2ad7748e7c06c681d05d5/href">https://medium.com/media/0d4bf30cb7a2ad7748e7c06c681d05d5/href</a></iframe><h4>bulk update command</h4><p>This command can be used for bulk updating packages in multiple projects under a solution folder.</p><p>— help or -h to list all parameters and descriptions</p><pre>$ nusight update -h</pre><p>- — solution or -s to specify the selected solution path, if you haven’t specified any solution path, it will take current directory as selected path</p><pre>$ nusight update -s=&lt;YOUR_PATH&gt;</pre><p>- — display or -d allows you only print ‘dotnet update’ commands on the screen, instead of executing it. If you don’t specify this, update commands will be run and update packages in the selected solution.</p><pre>$ nusight update -s=&lt;YOUR_PATH&gt; -d</pre><h4>Bulk remove command</h4><p>This can be used for bulk removing packages in multiple projects under a solution folder.</p><p>- — help or -h to list all parameters and descriptions</p><pre>$ nusight remove -h</pre><p>- — solution or -s to specify the selected solution path, if you haven’t specified any solution path, it will take current directory as selected path</p><pre>$ nusight remove -s=&lt;YOUR_PATH&gt;</pre><p>- — package or -p to specify the package name to be removed, if you want to select multiple packages, use comma separated values</p><pre>$ nusight remove -s=&lt;YOUR_PATH&gt; -p=Serilog</pre><p>- — display or -d allows you only print ‘dotnet remove’ commands on the screen, instead of executing it. If you don’t specify this, remove commands will be run and remove packages in the selected solution.</p><pre>$ nusight remove -s=&lt;YOUR_PATH&gt; -p=Serilog -d</pre><h4>Clone command</h4><p>This can be used for cloning all nuget packages from a source solution/project to a target project, this is handy if you have a template project and its nuget packages will always be used for any future projects, you can always clone your them to the new projects.</p><p>- — help or -h to list all parameters and descriptions</p><pre>$ nusight clone -h</pre><p>- — source or -s to specify the source solution path</p><pre>$ nusight clone -s=&lt;YOUR_PATH&gt;</pre><p>- — target or -t to specify the target project path, it must be a csproj</p><pre>$ nusight clone -s=&lt;YOUR_PATH&gt; -t=&lt;PROJECT&gt;.csproj</pre><p>- — display or -d allows you only print ‘dotnet install’ commands on the screen, instead of executing it. If you don’t specify this, install commands will be run and install packages in the target project.</p><pre>$ nusight clone -s=&lt;YOUR_PATH&gt; -t=&lt;PROJECT&gt;.csproj -d</pre><p>- — latest or -l to specify if you want to copy nuget packages from source solution with latest version.</p><pre>$ nusight clone -s=&lt;YOUR_PATH&gt; -t=&lt;PROJECT&gt;.csproj -l</pre><h4>Export command</h4><p>This can be used for exporting nuget package reference as json file.</p><p>- — help or -h to list all parameters and descriptions</p><pre>$ nusight export -h</pre><p>- — source or -s to specify the source solution path</p><pre>$ nusight export -s=&lt;YOUR_PATH&gt;</pre><p>- — file or -f to specify the exported file path and name</p><pre>$ nusight export -s=&lt;YOUR_PATH&gt; -f=&lt;FILE_NAME&gt;.json</pre><h4>Import command</h4><p>This can be used for importing nuget packages from an exported json file.</p><p>- — help or -h to list all parameters and descriptions</p><pre>$ nusight import -h</pre><p>- — solution or -s to specify the selected solution path to be imported to.</p><pre>$ nusight import -s=&lt;YOUR_PATH&gt;</pre><p>- — file or -f to specify the exported file path and name</p><pre>$ nusight import -s=&lt;YOUR_PATH&gt; -f=&lt;FILE_NAME&gt;.json</pre><p>- — display or -d allows you only print ‘dotnet install’ commands on the screen, instead of executing it. If you don’t specify this, install commands will be run and install packages in the target project.</p><pre>$ nusight import -s=&lt;YOUR_PATH&gt; -f=&lt;FILE_NAME&gt;.json -d</pre><h3>Finally,</h3><p>Congratulations on setup your NuSight &amp; I hope you enjoy using it to triage your .net solutions.</p><p>If you find my article is helpful, please click <strong>Applaud</strong> to support me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*Zmw2TEzK0e9KOq0_.png" /></figure><p>Here is the link to GitHub to grab the complete source code for the app.</p><p><a href="https://github.com/superwalnut/NuSight">superwalnut/NuSight</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1bf3e7ccfa5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>