Friday, January 26, 2024

Azure: Open Source Contributions to Azurite emulator for local Azure Storage

Microsoft has begun using AI to write its documentation. One such AI written article is Use the Azurite emulator for local Azure Storage development which contains text like the following:

The use of the word either in text means there should be two options when the AI written text provided three options (npm, Docker Hub or GitHub).

When contributing to a documentation that requires significant rewrite I often make a small change to see if there are active reviewers who can quickly approve the changes. The paragraph above from the Azurite documentation contains my first trial change specifically the text "Node Package Manager (npm)" which as of yesterday (January 25, 2024) was simply "Node Package Manager":


This page has a very active team approving PRs because my first trivial change was committed in under a day. Here is the email notifying me that the PR for the above change was merged causing the change to appear immediately on the Azurite documentation web page:








Wednesday, January 17, 2024

Azure: Naming Resources

Before creating an resource in Azure, a naming standard should be followed such as this one proposed by Microsoft, Define your naming convention. An excerpt from the aforementioned article is as follows which demonstrates one of the most commonly adopted naming standards with respect to Azure resources: 

The above naming strategy uses a prefix before each resource name that serves to identify the type of resource. Microsoft provides a comprehensive list of standard resource prefixes in in this document Abbreviation examples for Azure resources. The prefixes for some of the most communly used Azure resource types is as follows:

  • appi: Application Insights
  • asp: App Service Plan
  • cosmos: Azure Cosmos DB database (this is the name Azure uses which includes DB and database)
  • kv: Key Vault
  • logic: Logic App
  • sbq: Service Bus Queue
  • st: Storage Account

From the previous document the standard prefix for an Azure Function is func. An example of an Azure Function name created using Microsoft's naming convention is func-sometestfeature-dev-southcentralus-01:


Tuesday, January 16, 2024

Windows Services: Fix Online Documentation ServiceController

The following links related to the ServiceController class's documentation were likely written prior to 2002 (.NET 1.0 was released in January 2002) and the code samples in the documentation contain some C# examples that are functionally correct but are not written using best practices with respect to C# coding:

The following code was found in the above links where the code demarcated in boldface is not written using best practices:

The Status property above is used in the Console.WriteLine is an enumeration, ServiceControllerStatus, and there is no need to specify ToString().

The Equal method is used above to compare the Status property with a ServiceControllerService value. Best practice would be to use operator==.

The same code as above is show below without the superfluous ToString and using operator== instead other Equals method:



The above change was approved January 16, 2024 and merged into the main documentation branch:




Azure/PowerShell: Retrieving Azure Regions using Get-AzLocation

A standard for naming Azure resources has been proposed by Microsoft, Define your naming convention. The naming standard specifies that each Azure resource name contains a:

  • Resource type abbreviation
  • Workload/application
  • Environment (.e.g. dev, QA, stage, prod, etc.)
  • Azure region
  • Instance number

A programmatic means to retrieve the Azure regions used by resource name is provided by the Get-AzLocation PowerShell cmdlet. The documentation for Get-AzLocation (Get-AzLocation) describes the cmdlet's functionality as follows:

Get-AzLocation can be invoked as follows to return a list of Azure locations (regions) that can be used in resource names:

Connect-AzAccount

Get-AzLocation | Select-Object -ExpandProperty Location | Sort-Object

Azure regions are not static meaning regions are added and in theory could be removed. As of January 16, 2024 the Get-AzLocation script shown above returns the following list of Azure regions:

asia
asiapacific
australia
australiacentral
australiacentral2
australiaeast
australiasoutheast
brazil
brazilsouth
brazilsoutheast
canada
canadacentral
canadaeast
centralindia
centralus
centraluseuap
eastasia
eastus
eastus2
eastus2euap
europe
france
francecentral
francesouth
germany
germanynorth
germanywestcentral
global
india
israelcentral
italynorth
japan
japaneast
japanwest
korea
koreacentral
koreasouth
northcentralus
northeurope
norway
norwayeast
norwaywest
polandcentral
qatarcentral
singapore
southafrica
southafricanorth
southafricawest
southcentralus
southeastasia
southindia
sweden
swedencentral
switzerland
switzerlandnorth
switzerlandwest
uaecentral
uaenorth
uksouth
ukwest
unitedstates
westcentralus
westeurope
westindia
westus
westus2
westus3

Sunday, January 14, 2024

Docker: Identify Linux/Windows Container Support Requirements (Open Source Contribution)

The Docker documentation, Install Docker Desktop on Windows, specified at the bottom of the instructions the operating systems requirements to run Windows containers from Docker. I modified the page but at the same time the Docker documentation team split the system requirements into multiple pages (per-operating system) and made the same basic modification I had proposed to the documentation.

My PR was acknowledge as part of the changes:


The warning entitled, Important, at the bottom of this documentation was fundamentally the change proposed in close proximity to the specific version requirements:







Saturday, January 6, 2024

Git: Adding a Submodule to a Repo

Adding a Submodule

I was tasked with adding Opkg utilties to an existing git repo so these utilities could be invoke as part of the build pipeline. The Opkg project is found at:

The logical way to add the contents of a Opkg to to an exising git repo is byusing a git submodule. A submodule can be added to a repo by navigating to the folder in which the local repo resides: 

cd my-repo-folder


From inside the local repo's folder invoke:

git submodule add https://github.com/shr-project/opkg-utils


The command above creates a clone of the repo in folder opkg-utils and creates a .gitmodules file at the local repo's root. The .gitmodules file create is as follows:

[submodule "opkg-utils"]
        path = opkg-utils
        url = https://github.com/shr-project/opkg-utils


The following command shows the current changes related to any submodules:

git diff --cached --submodule


The output from the above code is as follows:

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..8205de2
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "opkg-utils"]
+       path = opkg-utils
+       url = https://github.com/shr-project/opkg-utils
Submodule opkg-utils 0000000...1f5c57b (new submodule)


The  value 1f5c57b above corresponds to the SHA code of the latest commit the the opkg-utils repo:

1f5c57bfc8c08926a349c395e0e72058f857448e

To perform a git add and git commit for the local repo, the following is invoked

git commit -am 'Task-123: Add Opkg as submodule'

The output from the above add/commit as follows:
 
warning: in the working copy of '.gitmodules', LF will be replaced by CRLF the next time Git touches it
[master 91e677e] Task-123: Add Opkg as submodule
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 opkg-utils

The mode, 160000, indicates opkg-utils is a submodule meaning in the repo, opkg-utils is a directory and not a sub directory.

The submodule can be committed to origin (the remote git repo) using the following command:

git push origin master

Note above that the branch name is master. It simply that I signed up for Azure DevOps over a decade above before there was a main branch and before it was called ADO.

In Azure DevOPs the opkg-utils folder looks as follows:


The SHA of the opkg-utils commit is contained in the opkg-util folder meaning the .submodules file is not where the SHA code is stored.

Cloning to Include the Submodule

To clone a repo add the --recurse-submodules parameter tot he standard git clone for the repo:
 
git clone --recurse-submodules https://<repo url here>

Forgetting to Clone with --recurse-submodules

If git clone is performed without --recurse-submodules then see the following to show how to add the the submodule or submodules to an already cloned git repo: Git: Get Submodules from an already Cloned Repo.