Content Developer II at Microsoft, working remotely in PA, TechBash conference organizer, former Microsoft MVP, Husband, Dad and Geek.
121813 stories
·
29 followers

Supporting the world’s most-used database engine through 2050

1 Share
Dr. Richard Hipp, creator of SQLite, shares how he taught himself to program, the challenges he faced in creating SQLite, and the importance of testing and maintaining the software for long-term support.
Read the whole story
alvinashcraft
3 hours ago
reply
West Grove, PA
Share this story
Delete

Introducing Infra Copilot - Unleashing GitHub Copilot for Infrastructure as Code

1 Share

umurugesan_9-1714107036189.jpeg

 

Introduction

In the ever-evolving landscape of infrastructure management, the demand for efficient, scalable, and reliable solutions has never been higher. As organizations increasingly embrace cloud-native architectures and adopt Infrastructure as Code (IaC) principles, the role of infrastructure professionals has expanded, presenting new challenges in the development and maintenance of infrastructure configurations.

 

The Challenges Faced by Infrastructure Professionals

  1. Complexity of IaC: Managing infrastructure through code introduces a layer of complexity. Infrastructure professionals often grapple with the intricate syntax and structure required by tools like Terraform and PowerShell. This complexity can lead to errors, delays, and increased cognitive load.
  2. Consistency Across Environments: Achieving consistency across multiple environments—development, testing, and production—poses a significant challenge. Maintaining uniformity in configurations is crucial for ensuring the reliability and stability of the deployed infrastructure.
  3. Learning Curve: The learning curve associated with IaC tools and languages can be steep for those new to the domain. As teams grow and diversify, onboarding members with varying levels of expertise becomes a hurdle.
  4. Time-Consuming Development Cycles: Crafting infrastructure code manually is a time-consuming process. Infrastructure professionals often find themselves reinventing the wheel, writing boilerplate code, and handling repetitive tasks that could be automated.

 

Enter Infra Copilot

What is Infra Copilot?

In response to these challenges, Leveraging GitHub Copilot to generate infra code specifically for infrastructure professionals—Infra Copilot. Infra Copilot is helping to revolutionize the way infrastructure is written, addressing the pain points experienced by professionals in the field.

The Significance of Infra Copilot

  1. Code Generation with Precision: Infra Copilot harnesses the power of machine learning to interpret the intent behind prompts and swiftly generate precise infrastructure code. It understands the context of infrastructure tasks, allowing professionals to express their requirements in natural language and receive corresponding code suggestions.
  2. Streamlining the IaC Development Process: By automating the generation of infrastructure code, Infra Copilot significantly streamlines the IaC development process. Infrastructure professionals can now focus on higher-level design decisions and business logic rather than wrestling with syntax intricacies.
  3. Consistency Across Environments and Projects: Infra Copilot ensures consistency across environments by generating standardized code snippets. Whether deploying resources in a development, testing, or production environment, Infra Copilot helps maintain uniformity in configurations.
  4. Accelerating Onboarding and Learning: For new team members and those less familiar with IaC, Infra Copilot serves as an invaluable learning tool. It provides real-time examples and best practices, fostering a collaborative environment where knowledge is shared seamlessly.
  5. Efficiency and Time Savings: The efficiency gains brought about by Infra Copilot are substantial. Infrastructure professionals can witness a dramatic reduction in development cycles, allowing for faster iteration and deployment of infrastructure changes.

Infra Copilot in Action

Prerequisites

      1.Install visual studio code latest version - https://code.visualstudio.com/download

  1. Have a GitHub Copilot license with a personal free trial or your company/enterprise GitHub account, install the Copilot extension, and sign in from Visual Studio Code. https://docs.github.com/en/copilot/quickstart
  2. Install the PowerShell extension for VS Code, as we are going to use PowerShell for our IaC sample.

umurugesan_10-1714107036223.png

Below is the PowerShell code generated using VS Code & GitHub Copilot. It demonstrates how to create a simple Azure VM.

We're employing a straightforward prompt with #, with the underlying code automatically generated within the VS Code editor.

umurugesan_11-1714107036243.png

 

Another example to create azure vm with vm scale set with minimum and maximum number of instance count. Prompt used with # in below example.

umurugesan_12-1714107036267.png

 

The PowerShell script generated above can be executed either from the local system or from the Azure Portal Cloud Shell. Similarly, we can create Terraform and devops code using this Infra Copilot.

 

Conclusion

In conclusion, Infra Copilot emerges as a game-changer in the realm of infrastructure as code, alleviating the challenges faced by professionals and ushering in a new era of efficiency and collaboration. As we wrap up our exploration of Infra Copilot's capabilities, the preceding examples have provided insight into its features, supported technologies, and practical applications. This comprehensive guide aims to equip infrastructure professionals with the knowledge to enhance their IaC workflows effectively.

 

Read the whole story
alvinashcraft
3 hours ago
reply
West Grove, PA
Share this story
Delete

Episode 464: Jana Werner on The Digital Transformation Card Game

1 Share

Coté interviews Jana Werner, Enterprise Transformation Lead EMEA, from Amazon Web Services (AWS). How can you start small changes to make big changes? That's the premise of Jana Werner's organization transformation card game. Sure, it's not really a "game," but each question is meant to help nudge management and executives a little closer to changing how they operate. Many of the ideas come from Amazon thinking, but many of the are also just the type of common sense that's too often uncommonly practiced. Coté interviews her about some of the cards, but, more importantly, the thinking, management philosophy, the life-style behind the cards.

Show Links

Contact Jana Werner

SDT News & Hype

The Cards

Here's the text of the all the cards:

Mechanism

  1. How can you remove 40% of the time required by a process within 45 days?
  2. How can you encourage and recognize experimentation with a community of practice?
  3. How can you use Amazon’s wheel of fortune to focus your operations meetings?
  4. How can you dive deep on one recurring problem to create a mechanism?
  5. How can you introduce Bar Raisers into hiring interviews to assess cultural fit/bar raising?
  6. How can you make visible how much of a product’s new functionality is actually used?
  7. How can you create your next prototype as a Minimum Loveable Product?
  8. How can you pick someone unfamiliar with your product to deep dive into the data and customer experience with?
  9. How can you use data to examine a decision that you made 2+ months ago for issues?
  10. How can you define your next business outcome as a Press Release?
  11. How can you visualise the decision-making for a process and eliminate 20% of the steps?
  12. How can you agree [on] the single threaded owner for each decision?
  13. How can you pick an organisational report, understand its purpose and eliminate or simplify it?
  14. How can you introduce recognition for best simplification of the quarter?
  15. How can you accelerate decision making by having more frequent, shorter senior meetings?

Culture

  1. How can you evidence that your next investment or product decision is what the customer really needs?
  2. How can you start leadership meetings with “one thing I learned this week” discussions?
  3. How can you create a feedback ritual at the end of each meeting?
  4. How can you work towards a safe meeting environment to practice "Disagree and Commit as a Principle?
  5. How can you give monthly recognition to the best cultural heck your organization has seen?
  6. How can you publicly discuss one of your “failures” and why the learnings were valuable?
  7. How can you run a culture hackathon, to identity hacks for a more agile culture?
  8. How can you schedule and protect time for retrospectives with learnings published?
  9. How can you dive deep when anecdotes and data conflict for a decision?
  10. How can you for every decisions ask what would need to be true to make the decisions faster?
  11. How can you replace weasel, words with data and customer anecdotes in business cases and reports?
  12. How can you identify a Day 2 behaviour to turn into a Day 1 behaviour with your team?
  13. How can you interview new hires within 2 months on good and bad culture observations?
  14. How can you start your next meeting with a document read?

Organisation

  1. How can you identify one emerging skill your organisation will need and create a learning path for it?
  2. How can you measure, reduce, and share learnings on the Bureaucratic Mass Index of a single team?
  3. How can you identity two-way door decisions und relinquish these to your teams?
  4. How can you stop using silos (“IT”) and instead use names (“Andy”)?
  5. How can you reduce “Keeping the Lights On” time and cost for one team?
  6. [REPEAT?] How can you start your next meeting with a quiet document read?
  7. How can you give your teams carte blanche for fast escalations?
  8. How can you identify one gate-keeper process that can be replaced with a guardrail or an automation?
  9. How can you change a KPI from an absolute achievement to one that shows continual improvement?

Leadership

  1. How can you use the Ladder of Inference to seek disconfirming data for key decisions.
  2. How can you identity “dogs not barking” in your leadership meetings and address these?
  3. How can you focus your next 1:1s on understanding employees' super powers?
  4. How can you create a shared understanding for phrases like “Digital Transformation” and “Agile” through lunch h-and-learn.
  5. How can you define team ambition and pride statements that resonate emotionally and intellectually?
  6. How can you create a press release describing where you imagine your organization to be in 3 years?
  7. How can you go around the room for feedback with the leader speaking last?
  8. How can you ask 10 employees about your organizations' priorities, vision, and their role in these?
  9. How can you define what makes you truly compensative using Wardley Maps or similar?
  10. How can you agree to what would help prioritize speed for your next two-way door decisions?
  11. How can you appoint and empower a single threaded leader for key initiatives?

SDT News & Hype

  • Join us in Slack.
  • Get a SDT Sticker! Send your postal address to stickers@softwaredefinedtalk.com and we will send you free laptop stickers!
  • Follow us: Twitch, Twitter, Instagram, Mastodon, BlueSky, LinkedIn, TikTok, Threads and YouTube.
  • Use the code SDT to get $20 off Coté’s book, Digital WTF, so $5 total.
  • Become a sponsor of Software Defined Talk!

Special Guest: Jana Werner.





Download audio: https://chtbl.com/track/E8DGG/aphid.fireside.fm/d/1437767933/9b74150b-3553-49dc-8332-f89bbbba9f92/c82e2023-77cc-48e4-b7dd-18c021e87a55.mp3
Read the whole story
alvinashcraft
3 hours ago
reply
West Grove, PA
Share this story
Delete

Blazor Basics: Localization Using Resource Files

1 Share

In this article, we will learn how to localize Blazor applications using resource files.

The solution shown in this article works for Blazor Server and the new Blazor Web App project template of .NET 8. However, it does not work for WebAssembly projects.

You can access the code used in this example on GitHub.

Introduction

We’re going to implement localization for a Blazor web application. It will allow us to translate the web app into multiple languages.

A Blazor application with a culture selector on the top right where you can select one of the supported languages. The content on the page and the menu is rendered in the selected langauge - German.

A Blazor application with a culture selector on the top right where you can select one of the supported languages. The content on the page and the menu is rendered in the selected langauge - English.

The completed project will look like this. It contains a language selector on the top right and displays the menu options on the left as well as the content of the Home page in the selected language.

Installing the Required NuGet Packages

Since we’re using .NET, we don’t have to reinvent the wheel. Our solution builds on top of the Microsoft.Extensions.Localization package.

In a newly created Blazor project based on .NET 8’s single project Blazor Web App project template, we install the package.

The Nuget Package Explorer with the Microsoft.Extensions.Localizations package installed and selected.

Next, we open the Program.cs file and add the required services to the service container.

builder.Services.AddLocalization();

We also need to set up the localization middleware on the application host. I suggest setting it up right after the builder.Build() call to make sure that the localization middleware runs as early as possible.

string[] supportedCultures = ["en-US", "de-CH"];
var localizationOptions = new RequestLocalizationOptions()
    .SetDefaultCulture(supportedCultures[0])
    .AddSupportedCultures(supportedCultures)
    .AddSupportedUICultures(supportedCultures);

app.UseRequestLocalization(localizationOptions);

We need to configure the UseRequestLocalization method with a RequestLocalizationOptions object. We use collection initializers and add en-US and de-CH as cultures. We then use the array to populate the required options.

Creating the Translation Files as Resource Files

We create a Locales folder that will contain our translated texts. Inside this folder, we create a new resource file and name it Resources.resx.

The resource system in .NET works with a custom tool. We need to open the file properties in the Solution Explorer and set the PublicResXFileCodeGenerator as the custom tool.

It comes with Visual Studio and should be installed out of the box. When we save the file, a designer file should be generated in the background. Whenever we add a resource to the dictionary and save the file, the designer file should be regenerated.

Hint: Sometimes, the designer file won’t be generated. You can either unload and reload the project in Visual Studio or restart Visual Studio. Most of the time, this will fix the issue. Otherwise, you might want to restart your computer.

Visual Studio with the English resources file opened.

Let’s add the resources we need for this demo application.

Next, we want to specify the culture of this resource file in its file name. We rename it from Resources.resx to Resources.en-US.resx. I learned that if we create the file with this name from the beginning, we have even more issues with the designer file generation.

We also create another resource file and name it Resources.de-CH.resx where we will store the German translations.

Visual Studio with the German resources file opened.

Now, we’re ready to use the localized strings in our Blazor application.

Using Resources in Blazor Components

In the Home page component, we replace the file content with the following code:

@page "/"
@using Microsoft.Extensions.Localization
@using BlazorLocalization.Locales;
@using System.Globalization
@inject IStringLocalizer<Resources> localizer

<PageTitle>@localizer["Home"]</PageTitle>

@Thread.CurrentThread.CurrentCulture;
@Thread.CurrentThread.CurrentUICulture;

<h1>@localizer["HomeTitle"]</h1>

@localizer["HomeText"]

We need a few using statements providing access to the Localization namespace as well as our Resources class containing the localized strings.

Hint: We can also move the using statements into the _Imports.razor file. It will allow us to access the classes within these namespaces without explicitly adding a using statement in each component.

Next, we use the inject directive to create an instance of the generic IStringLocalizer class. We provide our Resources class as the generic type argument.

The localizer exposes an indexer, providing us access to the translated strings. We use the following syntax to access the value in the HomeTitle token:

@localizer["HomeTitle"]

Accessing translated strings using the string localizer is straightforward.

We also want to use the string localizer in the NavMenu component to translate the menu items. We use the following code in the NavMenu.razor file:

@using Microsoft.Extensions.Localization
@using BlazorLocalization.Locales;
@using System.Globalization
@inject IStringLocalizer<Resources> localizer

<div class="top-row ps-3 navbar navbar-dark">
    <div class="container-fluid">
        <a class="navbar-brand" href="">Blazor Localization</a>
    </div>
</div>

<input type="checkbox" title="Navigation menu" class="navbar-toggler" />

<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
    <nav class="flex-column">
        <div class="nav-item px-3">
            <NavLink class="nav-link" href="" Match="NavLinkMatch.All">
                <span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> @localizer["MenuHome"]
            </NavLink>
        </div>

        <div class="nav-item px-3">
            <NavLink class="nav-link" href="counter">
                <span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> @localizer["MenuCounter"]
            </NavLink>
        </div>

        <div class="nav-item px-3">
            <NavLink class="nav-link" href="weather">
                <span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> @localizer["MenuWeather"]
            </NavLink>
        </div>
    </nav>
</div>

Again, we have a few using statements, and we use the indexer of the localizer variable of the generic type IStringLocalizer with the Resources class as its type argument.

The CultureSelector Component

Now that we have the translated texts in our resources files and know how to access the information in Blazor components, we want to be able to change cultures from within the Blazor application.

We create a new component in the Layouts folder, and name it CultureSelector, and insert the following code:

@inject NavigationManager Navigation
@using System.Globalization

<div>
    <select @bind="Culture">
        <option value="en-US">English</option>
        <option value="de-CH">German</option>
    </select>
</div>

@code
{
    protected override void OnInitialized()
    {
        Culture = CultureInfo.CurrentCulture;
    }

    private CultureInfo Culture
    {
        get
        {
            return CultureInfo.CurrentCulture;
        }
        set
        {
            if (CultureInfo.CurrentCulture != value)
            {
                var uri = new Uri(Navigation.Uri)
                    .GetComponents(UriComponents.PathAndQuery, UriFormat.Unescaped);
                var cultureEscaped = Uri.EscapeDataString(value.Name);
                var uriEscaped = Uri.EscapeDataString(uri);

                var fullUri = $"Culture/Set?culture={cultureEscaped}&redirectUri={uriEscaped}";
                Navigation.NavigateTo(fullUri, forceLoad: true);
            }
        }
    }
}

The component template uses an HTML select element that renders a dropdown including a list of all available cultures.

In the code section, we initialize the current culture using the CultureInfo class. We also implement a Culture property that we bind to the select element in the template code. It contains a simple getter and a more advanced setter.

In the setter, we check whether the selected value is different from the current culture. If that is true, we build an URI including the culture value and trigger an internal page navigation using the NavigationManager.

Make sure to provide true to the forceLoad argument to ensure that the internal navigation will be executed.

Handling Culture Changes Using a Controller

Whenever we select a different culture in the CultureSelector component, an internal page navigation should happen. However, we haven’t implemented the target page yet.

Let’s add a new Controllers folder in the root folder and create an empty MVC controller named CultureController for the basis of the following controller implementation.

using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;

namespace BlazorLocalization.Controllers;

[Route("[controller]/[action]")]
public class CultureController : Controller
{
    public IActionResult Set(string culture, string redirectUri)
    {
        if (culture != null)
        {
            var requestCulture = new RequestCulture(culture, culture);
            var cookieName = CookieRequestCultureProvider.DefaultCookieName;
            var cookieValue = CookieRequestCultureProvider.MakeCookieValue(requestCulture);

            HttpContext.Response.Cookies.Append(cookieName, cookieValue);
        }

        return LocalRedirect(redirectUri);
    }
}

We implement a Set method that accepts two parameters. It has a culture and a redirectUri argument, both of type string.

If the provided culture isn’t null, we create a new instance of the built-in RequestCulture object and provide the instances as the value of a cookie.

When using the Localization NuGet package installed at the beginning, we can choose from different options, how to change the culture. Using cookies is one of the simplest solutions, and it has worked great for me so far.

At the end of the method, we need to make sure that we append the created cookie to the response of our HTTP request and execute the redirect to the redirectUri.

To make the Blazor application aware of the newly implemented controller, we need to register the services handling ASP.NET Core Controllers in the Program.cs file.

We add the following line after the AddLocalization call:

builder.Services.AddControllers();

And we also need to add the following middleware registration on the web application host:

app.MapControllers();

The order doesn’t matter much, but I usually register the controllers before the MapRazorComponent<App>() registration.

Conclusion

The Microsoft.Extensions.Localization NuGet package provides us with types that allow us to implement localization with a few lines of code and well-known .NET tools, such as resource files.

Make sure to register the required services in the Program.cs file, and you should be good to go pretty quickly.

If you want to have more type safety when accessing the localized strings, you could also implement an enum containing the keys of the resource files and use the enum instead of magic strings when using the indexer of the IStringLocalizer interface.

If you want to learn more about Blazor development, you can watch my free Blazor Crash Course on YouTube. And stay tuned to the Telerik blog for more Blazor Basics.

Read the whole story
alvinashcraft
3 hours ago
reply
West Grove, PA
Share this story
Delete

How to Create a Zip File in Memory In C#

1 Share

In this article, we will look at how we create In-Memory Zip files in C#. Previously, we discussed how to create and read Zip files in .NET in our Working With Zip Files in C#/.NET article, so we recommend taking a look at that to familiarize yourself with working with Zip files. Let’s delve in. […]

The post How to Create a Zip File in Memory In C# appeared first on Code Maze.

Read the whole story
alvinashcraft
3 hours ago
reply
West Grove, PA
Share this story
Delete

Collection Performance: Is LINQ Always the Most Performant Choice?

1 Share
The article explores the performance implications of using LINQ for collection queries, finding that a conventional foreach() loop outperforms LINQ by 1.75 times in identifying items matching a given query. The conclusion suggests benchmarking to determine the optimal approach based on the nature of the query and elements being sought.







Read the whole story
alvinashcraft
3 hours ago
reply
West Grove, PA
Share this story
Delete
Next Page of Stories