Arch Linux: How to - Pacman parallel package download

Arch Linux: How to - Pacman parallel package download

Hello Everyone

If you are using Arch Linux or any Arch Linux based distro, you might got tired with slow single package download with pacman.

From pacman v6, parallel download feature has been added.

To have this, all you have to do

  1. Open file /etc/pacman.conf

  2. Inside file, there will be a section called # Misc options, under the section add below line, if its not there. if its there commented, remove the hash.

ParallelDownloads = 5
  1. Save and exit from the file.

  2. In your terminal type

sudo pacman -Syyu

And you will see blazing speed package download.

Hope it helps.

Az-204 - Prep - How To - Creating a container and access its service in Azure environment with ACR

Hello Team, 

Below commands can be used to create a container with image from ACR and to access the container service.


az login \
--username <> \
--password <> \

az group list | select -p name

# Deploying a container from public registry
az container create \
--resource-group "1-028b2503-playground-sandbox" \
--name psdemo-hello-world-cli-010 \
--dns-name-label psdemo-hello-world-cli-010 \
--image mcr.microsoft.com/azuredocs/aci-helloworld \
--ports 80

# show the container info
az container show --resource-group "1-5e3dbe31-playground-sandbox" \
--name "psdemo-hello-world-cli-009"

# Retrieve the container URL to access it over internet
URL=$(az container show --resource-group '1-5e3dbe31-playground-sandbox' \
--name 'psdemo-hello-world-cli-009' --query ipAddress.fqdn | tr -d '"')
echo "https://$URL"

# Demo 1 - Deploy container from azure container registry
## STEP 0 SET ENVIRONMENT VARIABLES
ACR_NAME="grsr18"
ACR_REGISTRY_ID=$(az acr show --name $ACR_NAME --query id --output tsv)
ACR_LOGINSERVER=$(az acr show --name $ACR_NAME --query loginServer --output tsv)

echo "ACR ID: $ACR_REGISTRY_ID"
echo "ACR_LOGINSERVER $ACR_LOGINSERVER"

## STEP 1 create a service principal and get the password and ID,
## this will allow azure container instances to pull
SP_NAME=acr-service-principal
SP_PASSWD=$(az ad sp create-for-rbac \
--name http://$ACR_NAME-pull \
--scopes $ACR_REGISTRY_ID \
--role acrpull \
--query password \
--output tsv)
SP_APPID=$(az ad sp show --id http://$ACR_NAME-pull --query appId --output tsv)

echo "Servce Princial ID : $SP_APPID"
echo "Service Princial Password $SP_PASSWD"

## STEP 2
az container create \
--resource-group "1-5e3dbe31-playground-sandbox" \
--name "psdemo-webapp-cli" \
--dns-name-label psdemo-webapp-cli \
--ports 80 \
--image $ACR_LOGINSERVER/webappimage:v1 \
--registry-login-server $ACR_LOGINSERVER \
--registry-username $SP_APPID \
--registry-password $SP_PASSWD

# due to permission issues if you cant create service princial
# then you can use your acr login creds to pull image
az container create --resource-group "1-028b2503-playground-sandbox" \
--name "psdemo-webapp-cli" --dns-name-label "psdemo-webapp-cli" \
--ports 80 --image $ACR_LOGINSERVER/webappimage:v1 \
--registry-login-server $ACR_LOGINSERVER --registry-username "GRSR18" \
--registry-password "xx=xxxxx=xxxxx+xxxxx"

# get the container status
az container show --resource-group "1-028b2503-playground-sandbox" \
--name "psdemo-webapp-cli"
az container show --resource-group "1-028b2503-playground-sandbox" \
--name "psdemo-webapp-cli" --query instanceView.state

# get the FQDN to access
url=$(az container show --resource-group "1-028b2503-playground-sandbox" \
--name "psdemo-webapp-cli" --query ipAddress.fqdn | tr -d '"')
echo http://$url
curl http://$url

# Get contianer logs
az container logs --resource-group "1-028b2503-playground-sandbox" \
--name "psdemo-webapp-cli"

# Delete the running container
az container delete --resource-group "1-028b2503-playground-sandbox" \
--name "psdemo-webapp-cli" --yes

# Cleanup from our demos, all ACIs and ACR Deployed in the resource group
az group delete --name "1-028b2503-playground-sandbox" --yes
docker image rm grsr18.azureacr.ip/webappimage:v1
docker image rm webappimage:v1



Az-204 - Prep - How To - Creating Azure Container Registry And Upload/Push docker image into Azure Container Registry (ACR)

 

Hello Everyone, 

This post contains below list of topics

  1. How to create ACR ( Azure Container Registry )
  2. How to login into ACR
  3. How to push Docker images into ACR
  4. How to build docker images with ACR
Github link contains a sample dotnet webapp, which we can build using given instructions. I will share the Github link soon. But you can build your own container image and upload it ACR with same instructions as give below.
# Login
az login --username "xxxx" --password "xxxx"

# Get the resource group name
az group list

# if you want to set subscription
az account set --subscription "SUB NAme"

# create a rg
az group create \
--name psdemo-rg \
--location centralus

# or list existing with

az group list

# Set ACR name , globally unique
ACR_NAME="GRSR810"
az acr create \
--resource-group "1-028b2503-playground-sandbox" \
--name $ACR_NAME \
--sku Standard

# login into ACR
az acr login --name $ACR_NAME

# Get the login server which is used in the image tag
az acr show --name $ACR_NAME --query loginServer
az acr show --name $ACR_NAME --query loginServer --output tsv
ACR_LOGINSERVER=$(az acr show --name $ACR_NAME --query loginServer --output tsv)
echo $ACR_LOGINSERVER

Tag the container image using the login server name.
docker image ls webappimage:v1
docker tag webappimage:v1 $ACR_LOGINSERVER/webappimage:v1
docker image ls $ACR_LOGINSERVER/webappimage:v1
docker image ls

# Push the image into Docker registry
docker push $ACR_LOGINSERVER/webappimage:v1

# Get list of the repositories and images/tags from ACR
az acr repository list --name $ACR_NAME --output table
az acr repository show-tags --name $ACR_NAME --repository webappimage --output table

# By using tasks we can build ACR with tasks.
az acr build --image "webappimage:v1-acr-task" --registry $ACR_NAME .

# 2 images must be there now
az acr repository show-tags --name $ACR_NAME --repository webappimage --output table


Dockerfile

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1

RUN mkdir /app
WORKDIR /app

COPY ./webapp/bin/Release/netcoreapp3.1/publish ./
COPY ./config.sh ./

RUN bash config.sh

EXPOSE 80
ENTRYPOINT [ "dotnet", "webapp.dll" ]

Building dotnet Web application

ls -ls ./webapp

dotnet build ./webapp
dotnet run --project ./webapp
curl http://localhost:5000

# Publish local build
dotnet publish -c Release ./webapp

# build docker image
docker build -t webappimage:v1 .

# Run the container
docker run --name webapp --publish 8080:80 --detach webappimage:v1
curl http://localhost:8080

docker stop webapp
docker rm webapp

docker image ls webappimage:v1


How to install .Net core SDK in Mac OS ?

 Hello Everyone,

As the official website not having full instructions,I am writing this article about installing .Net code SDK in Mac OS.

Step1: As usual, go to microsfot website https://dotnet.microsoft.com/download and choose what version of .Net SDK you want. Download and install it. 

As per the installation guide in the webpage, you have to execute in the terminal `dotnet` you will expect to output similar to this

PS az204_prep> dotnet


Usage: dotnet [options]
Usage: dotnet [path-to-application]
Options:
-h|--help Display help.
--info Display .NET Core information.
--list-sdks Display the installed SDKs.
--list-runtimes Display the installed runtimes.
path-to-application:
The path to an application .dll file to execute.
PS az204_prep>

But instead that you will get

zsh: command not found: dotnet

To resolve this error verify you can find dotnet binary in /usr/local/share/ location with ls.

✘  ~  ls /usr/local/share/dotnet/dotnet
/usr/local/share/dotnet/dotnet

Then simplay either add to your shell PATH with export command and source your shell file.

 
 
export PATH="$PATH:/usr/local/share/dotnet/dotnet"
 

Or create a soft link into /usr/loca/bin directory

 
  ~  ls /usr/local/share/dotnet/dotnet
/usr/local/share/dotnet/dotnet
 

Hope it helps you.

Thank you.


 

Az-204 - Prep - How To - Creating VM Using Azure Powershell

 

Hello Everyone, 

Please find below commands to create VM using azure powershell

 

# Login
Connect-AzAccount -SubscriptionName "Demo Account"

# Set your subscription
Set-AzContext -SubscriptionName "Demo Account"

# Create a resource Group
New-AzResourceGroup -Name "psdemo-rg" -Location "CentralUS"

# Create a credential to use in VM Creation
$username = 'cloud_user_p_25e585de'
$password = ConvertTo-SecureString 'c6Wh3BrR6ArHzO&Cx4cA' -AsPlainText -Force
$WindowsCred = New-Object System.Management.Automation.PSCredential ($username, $password)

# Create Windows VM
New-AzVM `
-ResourceGroupName 'psdemo-rg' `
-Name 'psdemo-win-az4' `
-Image 'Win2019Datacenter'`
-Credential $WindowsCred `
-OpenPorts 3389 `
-AzJob

Get-AzResourceGroup
# 1-83eb7c26-playground-sandbox

New-AzVM `
-ResourceGroupName "1-83eb7c26-playground-sandbox" `
-Name "psdemo-win-az1" `
-Image "Win2019Datacenter" `
-Credential $WindowsCred `
-OpenPorts 3389

New-AzVm `
-ResourceGroupName "1-83eb7c26-playground-sandbox" `
-Name "aznewvm23" `
-Location 'eastus' `
-VirtualNetworkName "mynewazvm23" `
-SubnetName "default" `
-SecurityGroupName "mynewvmNSG23" `
-PublicIpAddressName "mypublicip23" `
-OpenPorts 80,3389 `
-AsJob

Get-Job 1

$j = Get-Job -Name "Long Running*"
$j

"""
PS my_learning/az204_prep> $j = Get-Job -Name 'Long Running*'

PS my_learning/az204_prep> $j


Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 Long Running O… AzureLongRunni… Failed True localhost New-AzVM
2 Long Running O… AzureLongRunni… Failed True localhost New-AzVM
3 Long Running O… AzureLongRunni… Completed True localhost New-AzVM
"""

Get-AzVM -ResourceGroupName 1-83eb7c26-playground-sandbox

# Get the Public IP Address
Get-AzPublicIpAddress `
-ResourceGroupName "1-83eb7c26-playground-sandbox"`
-Name "psdemo-win-az" | Select-Object IpAddress

# Remove resource group after demo
Remove-AzResourceGroup -Name '1-83eb7c26-playground-sandbox'

Az-204 - Prep - How To - Creating VM Using Azure CLI - Bash

Hello Everyone, 

Please find below commands to create VM using azure cli `az`

# login and set a subscription
az login
az account set --subscription "Demo Account"

# List all created RGs
az group list --output table

# create a RG
az group create \
--name "psdemo-rg" \
--location "centralus"

# Creating a Windows VM
az vm create \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-win-cli" \
--image "win2019datacenter" \
--admin-username "demoadmin" \
--admin-password "password@123" \
--public-ip-sku "Standard"

# Open RDP Port for remote access (( Might open already))
az vm open-port \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-win-cli" \
--port "3389"

# get the Public IP Address for remote access
az vm list-ip-addresses \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-win-cli" \
--output table


# Creating a Linux VM
az vm create \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-linux-cli" \
--image "UbuntuLTS" \
--admin-username "demoadmin" \
--authentication "ssh" \
--ssh-key-value ~/.ssh/id_rsa.pub \
--public-ip-sku "Standard"

# open port 22 ((Might open already ))
az vm open-port \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-linux-cli" \
--port 22

# get the public IP Address
az vm list-ip-addresses \
--resource-group "1-718a377a-playground-sandbox" \
--name "psdemo-linux-cli" \
--output table

# verify login
ssh demoadmin@52.165.189.38


# Cleanup the resources
az group delete --name "1-718a377a-playground-sandbox"