diff --git a/Demos/04-FunctionApps/readme.md b/Demos/04-FunctionApps/readme.md index 33e94578..1e21f188 100644 --- a/Demos/04-FunctionApps/readme.md +++ b/Demos/04-FunctionApps/readme.md @@ -16,6 +16,8 @@ [Azure Functions Reference](https://docs.microsoft.com/en-gb/azure/azure-functions/functions-reference) +[Event-driven scaling in Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/event-driven-scaling) + [Quickstarts - Available for different frameworks](https://docs.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-java) ## CLI Reference diff --git a/Setup/windows-subsystem-linux/all-in-one.sh b/Setup/windows-subsystem-linux/all-in-one.sh new file mode 100644 index 00000000..a38bbeda --- /dev/null +++ b/Setup/windows-subsystem-linux/all-in-one.sh @@ -0,0 +1,24 @@ +sudo apt update + +# node +sudo curl -sL https://deb.nodesource.com/setup_14.x | sudo bash +sudo apt-get install -y nodejs + +# .net +wget https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb +sudo dpkg -i packages-microsoft-prod.deb + +sudo apt-get install -y apt-transport-https && \ +sudo apt-get update && \ +sudo apt-get install -y dotnet-sdk-3.1 + +sudo apt-get install -y apt-transport-https && \ +sudo apt-get update && \ +sudo apt-get install -y dotnet-sdk-6.0 + +# azure cli +curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash +az config set extension.use_dynamic_install=yes + +# function core tools +sudo npm install -g azure-functions-core-tools@4 --unsafe-perm true \ No newline at end of file diff --git a/Setup/windows-subsystem-linux/install-net.sh b/Setup/windows-subsystem-linux/install-net.sh index 59fb072b..fa64d184 100644 --- a/Setup/windows-subsystem-linux/install-net.sh +++ b/Setup/windows-subsystem-linux/install-net.sh @@ -2,9 +2,9 @@ wget https://packages.microsoft.com/config/ubuntu/20.10/packages-microsoft-prod. sudo dpkg -i packages-microsoft-prod.deb sudo apt-get update; \ - sudo apt-get install -y apt-transport-https && \ - sudo apt-get update && \ - sudo apt-get install -y dotnet-sdk-3.1 +sudo apt-get install -y apt-transport-https && \ +sudo apt-get update && \ +sudo apt-get install -y dotnet-sdk-3.1 sudo apt-get update; \ sudo apt-get install -y apt-transport-https && \ diff --git a/Tooling/01-Github/_images/commits.png b/Tooling/01-Git/_images/commits.png similarity index 100% rename from Tooling/01-Github/_images/commits.png rename to Tooling/01-Git/_images/commits.png diff --git a/Tooling/01-Github/_images/forking-workflow.jpg b/Tooling/01-Git/_images/forking-workflow.jpg similarity index 100% rename from Tooling/01-Github/_images/forking-workflow.jpg rename to Tooling/01-Git/_images/forking-workflow.jpg diff --git a/Tooling/01-Github/_images/git-flow.png b/Tooling/01-Git/_images/git-flow.png similarity index 100% rename from Tooling/01-Github/_images/git-flow.png rename to Tooling/01-Git/_images/git-flow.png diff --git a/Tooling/01-Github/_images/sha1.png b/Tooling/01-Git/_images/sha1.png similarity index 100% rename from Tooling/01-Github/_images/sha1.png rename to Tooling/01-Git/_images/sha1.png diff --git a/Tooling/01-Github/_images/update.jpg b/Tooling/01-Git/_images/update.jpg similarity index 100% rename from Tooling/01-Github/_images/update.jpg rename to Tooling/01-Git/_images/update.jpg diff --git a/Tooling/01-Github/readme.md b/Tooling/01-Git/readme.md similarity index 86% rename from Tooling/01-Github/readme.md rename to Tooling/01-Git/readme.md index 4583dc11..ffc395a3 100644 --- a/Tooling/01-Github/readme.md +++ b/Tooling/01-Git/readme.md @@ -6,8 +6,6 @@ [Git Graph VS Code](https://marketplace.visualstudio.com/items?itemName=mhutchie.git-graph) -[Git History Diff](https://marketplace.visualstudio.com/items?itemName=huizhou.githd) - # Git / Github Essentials ## Configuration @@ -129,6 +127,50 @@ git branch save-detached-head > Note: You will have to switch to the branch you saved to afterwards +## Changing Branches + +Saving work befor switching the branch - alternative to stage and commit: + +``` +git stash | git stash push +``` + +List stashes: + +``` +git stash list +``` + +Use a stash: + +``` +git stash apply | git stash apply stash@{2} +``` + +Switch to Branch: + +``` +git checkout [name_of_your_branch] +``` + +Cleaning up after branch switches - ie to remove untracked files from other branches on local disk: + +-n flag is used to perform dry run. +-f flag is used to remove untracked files. +-fd flag is used to remove untracked files and folders. +-fx flag is used to remove untracked and ignored files. + +``` +git clean -fd | git clean -f folderpath +``` + +Update a Branch from master / main: + +``` +git fetch +git rebase origin/master +``` + ## Tags Create Lightweight tag : @@ -302,6 +344,6 @@ git flow release finish RELEASE ## Additional Labs & Walkthroughs -[Introduction to Git](https://docs.microsoft.com/en-us/learn/modules/intro-to-git/) - [Learning Path - Introduction to version control with Git](https://docs.microsoft.com/en-us/learn/paths/intro-to-vc-git/) + +[Learning Path - Manage Source Control (GitHub)](https://learn.microsoft.com/en-us/training/paths/az-400-manage-source-control/) diff --git a/Tooling/08-Docker-WSL/configure-wsl2.ps1 b/Tooling/08-Docker-WSL/configure-wsl2.ps1 deleted file mode 100644 index e305bf59..00000000 --- a/Tooling/08-Docker-WSL/configure-wsl2.ps1 +++ /dev/null @@ -1,2 +0,0 @@ - -https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi \ No newline at end of file diff --git a/Tooling/08-Docker-WSL/readme.md b/Tooling/08-Docker-WSL/readme.md index d5a10a5b..20085f3f 100644 --- a/Tooling/08-Docker-WSL/readme.md +++ b/Tooling/08-Docker-WSL/readme.md @@ -18,26 +18,13 @@ Check Docker Settings: #### Install WSL2 -Execute script `setup-wsl2.ps1` multible times to setup WSL2. +Open PowerShell as Administrator and run: ```powershell -Set-ExecutionPolicy Bypass -Scope Process -Force; -Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/arambazamba/az-204/main/Tooling/08-Docker-WSL/setup-wsl2.ps1')) +wsl --install ``` -First Run: - -![finish-sw](_images/finish-sw.jpg) - ->Note: Reboot between first and second run. - -Second Run: - -![select-distro](_images/select-distro.jpg) - -After the second run your selected linux distro will be opened an you can set your username: - -> Note: You can take the same credntials just like on the Windows VM +Reboot your machine & open WSL and set your root user & password: ``` user=azlabadmin diff --git a/Tooling/08-Docker-WSL/setup-wsl2.ps1 b/Tooling/08-Docker-WSL/setup-wsl2.ps1 deleted file mode 100644 index 5d300425..00000000 --- a/Tooling/08-Docker-WSL/setup-wsl2.ps1 +++ /dev/null @@ -1,279 +0,0 @@ -# Install WSL -# This script needs to be run as a priviledged user - -Write-Host("Installing Docker Desktop") -choco install docker-desktop -y - -Write-Host("Checking for Windows Subsystem for Linux...") -$rebootRequired = $false -if ((Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux).State -ne 'Enabled'){ - Write-Host(" ...Installing Windows Subsystem for Linux.") - $wslinst = Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName Microsoft-Windows-Subsystem-Linux - if ($wslinst.Restartneeded -eq $true){ - $rebootRequired = $true - } -} else { - Write-Host(" ...Windows Subsystem for Linux already installed.") -} - -Write-Host("Checking for Virtual Machine Platform...") -if ((Get-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform).State -ne 'Enabled'){ - Write-Host(" ...Installing Virtual Machine Platform.") - $vmpinst = Enable-WindowsOptionalFeature -Online -NoRestart -FeatureName VirtualMachinePlatform - if ($vmpinst.RestartNeeded -eq $true){ - $rebootRequired = $true - } -} else { - Write-Host(" ...Virtual Machine Platform already installed.") -} - -function Update-Kernel () { - Write-Host(" ...Downloading WSL2 Kernel Update.") - $kernelURI = 'https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi' - $kernelUpdate = ((Get-Location).Path) + '\wsl_update_x64.msi' - (New-Object System.Net.WebClient).DownloadFile($kernelURI, $kernelUpdate) - Write-Host(" ...Installing WSL2 Kernel Update.") - msiexec /i $kernelUpdate /qn - Start-Sleep -Seconds 5 - Write-Host(" ...Cleaning up Kernel Update installer.") - Remove-Item -Path $kernelUpdate -} - -function Get-Kernel-Updated () { - # Check for Kernel Update Package - Write-Host("Checking for Windows Subsystem for Linux Update...") - $uninstall64 = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | ForEach-Object { Get-ItemProperty $_.PSPath } | Select-Object DisplayName, Publisher, DisplayVersion, InstallDate - if ($uninstall64.DisplayName -contains 'Windows Subsystem for Linux Update') { - return $true - } else { - return $false - } -} - -$pkgs = (Get-AppxPackage).Name - -function Get-WSLlist { - $wslinstalls = New-Object Collections.Generic.List[String] - $(wsl -l) | ForEach-Object { if ($_.Length -gt 1){ $wslinstalls.Add($_) } } - $wslinstalls = $wslinstalls | Where-Object { $_ -ne 'Windows Subsystem for Linux Distributions:' } - return $wslinstalls -} -function Get-WSLExistance ($distro) { - # Check for the existence of a distro - # return Installed as Bool - $wslImport = $false - if (($distro.AppxName).Length -eq 0){ $wslImport = $true } - $installed = $false - if ( $wslImport -eq $false ){ - if ($pkgs -match $distro.AppxName) { - $installed = $true - } - } else { - if (Get-WSLlist -contains ($distro.Name).Replace("-", " ")){ - $installed = $true - } - } - return $installed -} - -function Get-StoreDownloadLink ($distro) { - # Uses $distro.StoreLink to get $distro.URI - # Required when URI is not hard-coded - #### Thanks to MattiasC85 for this excelent method of getting Microsoft Store download URIs #### - # Source: https://github.com/MattiasC85/Scripts/blob/a1163b97875ed075927438505808622614a9961f/OSD/Download-AppxFromStore.ps1 - $wchttp=[System.Net.WebClient]::new() - $URI = "https://store.rg-adguard.net/api/GetFiles" - $myParameters = "type=url&url=$($distro.StoreLink)" - $wchttp.Headers[[System.Net.HttpRequestHeader]::ContentType]="application/x-www-form-urlencoded" - $HtmlResult = $wchttp.UploadString($URI, $myParameters) - $Start=$HtmlResult.IndexOf("

The links were successfully received from the Microsoft Store server.

") - if ($Start -eq -1) { - write-host "Could not get Microsoft Store download URI, please check the StoreURL." - exit - } - $TableEnd=($HtmlResult.LastIndexOf("")+8) - $SemiCleaned=$HtmlResult.Substring($start,$TableEnd-$start) - $newHtml=New-Object -ComObject "HTMLFile" - $src = [System.Text.Encoding]::Unicode.GetBytes($SemiCleaned) - $newHtml.write($src) - $ToDownload=$newHtml.getElementsByTagName("a") | Select-Object textContent, href - $apxLinks = @() - $ToDownload | Foreach-Object { - if ($_.textContent -match '.appxbundle') { - $apxLinks = $_ - } - } - $distro.URI = $apxLinks.href - return $distro -} - -function Select-Distro () { - # See: https://docs.microsoft.com/en-us/windows/wsl/install-manual - # You can also use https://store.rg-adguard.net to get Appx links from Windows Store links - $distrolist = ( - [PSCustomObject]@{ - 'Name' = 'Ubuntu 20.04' - 'StoreLink' = 'https://www.microsoft.com/en-us/p/ubuntu-2004-lts/9n6svws3rx71' - 'URI' = '' - 'AppxName' = 'CanonicalGroupLimited.Ubuntu20.04onWindows' - 'winpe' = 'ubuntu2004.exe' - 'installed' = $false - }, - [PSCustomObject]@{ - 'Name' = 'Ubuntu 18.04' - 'URI' = 'https://aka.ms/wsl-ubuntu-1804' - 'AppxName' = 'CanonicalGroupLimited.Ubuntu18.04onWindows' - 'winpe' = 'ubuntu1804.exe' - 'installed' = $false - }, - [PSCustomObject]@{ - 'Name' = 'Ubuntu 16.04' - 'URI' = 'https://aka.ms/wsl-ubuntu-1604' - 'AppxName' = 'CanonicalGroupLimited.Ubuntu16.04onWindows' - 'winpe' = 'ubuntu1604.exe' - 'installed' = $false - }, - [PSCustomObject]@{ - 'Name' = 'Debian' - 'URI' = 'https://aka.ms/wsl-debian-gnulinux' - 'AppxName' = 'TheDebianProject.DebianGNULinux' - 'winpe' = 'debian.exe' - 'installed' = $false - }, - [PSCustomObject]@{ - 'Name' = 'Kali' - 'URI' = 'https://aka.ms/wsl-kali-linux-new' - 'AppxName' = 'KaliLinux' - 'winpe' = 'kali.exe' - 'installed' = $false - }, - [PSCustomObject]@{ - 'Name' = 'OpenSUSE Leap 42' - 'URI' = 'https://aka.ms/wsl-opensuse-42' - 'AppxName' = 'openSUSELeap42' - 'winpe' = 'openSUSE-42.exe' - 'installed' = $false - }, - [PSCustomObject]@{ - 'Name' = 'SUSE Linux Enterprise Server 12' - 'URI' = 'https://aka.ms/wsl-sles-12' - 'AppxName' = 'SUSELinuxEnterpriseServer12' - 'winpe' = 'SLES-12.exe' - 'installed' = $false - }, - [PSCustomObject]@{ - 'Name' = 'Alpine' - 'StoreLink' = 'https://www.microsoft.com/en-us/p/alpine-wsl/9p804crf0395' - 'URI' = '' - 'AppxName' = 'AlpineWSL' - 'winpe' = 'Alpine.exe' - 'installed' = $false - } - # [PSCustomObject]@{ - # 'Name' = 'Fedora Remix for WSL' - # 'URI' = 'https://github.com/WhitewaterFoundry/Fedora-Remix-for-WSL/releases/download/31.5.0/Fedora-Remix-for-WSL_31.5.0.0_x64_arm64.appxbundle' - # 'AppxName' = 'FedoraRemix' - # 'winpe' = 'fedora.exe' - # 'installed' = $false - # 'sideloadreqd' = $true # Sideloading not supported by this script... yet - # }, - # [PSCustomObject]@{ - # 'Name' = 'Ubuntu 20.04' - # 'URI' = 'https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz' - # 'AppxName' = '' # Leave blank for wsl --import install - # 'winpe' = '' - # 'installed' = $false - # } - ) - $distrolist | ForEach-Object { $_.installed = Get-WSLExistance($_) } - Write-Host("+------------------------------------------------+") - Write-Host("| Choose your Distro |") - Write-Host("| Ubuntu 18.04 is recommended for Docker on WSL2 |") - Write-Host("+------------------------------------------------+") - For ($i = 0; $i -le ($distrolist.Length - 1); $i++) { - $installedTxt = "" - if (($distrolist.installed)[$i]) { - $installedTxt = "(Installed)" - } - Write-Host(($i + 1).ToString() + " " + ($distrolist.Name)[$i] + " " + $installedTxt) - } - $distroChoice = Read-Host '>' - $choiceNum = 0 - if (($distroChoice.Length -ne 0) -and ($distroChoice -match '^\d+$')) { - if (($distroChoice -gt 0) -and ($distroChoice -le $distrolist.Length)) { - $choiceNum = ($distroChoice - 1) - } - } - $choice = $distrolist[$choiceNum] - return $choice -} - -function Install-Distro ($distro) { - function Import-WSL ($distro) { - $distroinstall = "$env:LOCALAPPDATA\lxss" - $wslname = $($distro.Name).Replace(" ", "-") - $Filename = $wslname + ".rootfs.tar.gz" - Write-Host(" ...Downloading " + $distro.Name + ".") - Invoke-WebRequest -Uri $distro.URI -OutFile $Filename -UseBasicParsing - wsl.exe --import $wslname $distroinstall $Filename - } - function Add-WSLAppx ($distro) { - # ToDo: Check if sideloading is required - $Filename = "$($distro.AppxName).appx" - $ProgressPreference = 'SilentlyContinue' - Write-Host(" ...Downloading " + $distro.Name + ".") - if ($distro.URI.Length -lt 2) { - $distro = Get-StoreDownloadLink($distro) # Handle dynamic URIs - } - Invoke-WebRequest -Uri $distro.URI -OutFile $Filename -UseBasicParsing - Write-Host(" ...Beginning " + $distro.Name + " install.") - Add-AppxPackage -Path $Filename - Start-Sleep -Seconds 5 - } - if (Get-WSLExistance($distro)) { - Write-Host(" ...Found an existing " + $distro.Name + " install") - } else { - if ($($distro.AppxName).Length -gt 1){ - Add-WSLAppx($distro) - } else { - Import-WSL($distro) - } - } -} - -if ($rebootRequired) { - shutdown /t 120 /r /c "Reboot required to finish installing WSL2" - $cancelReboot = Read-Host 'Cancel reboot for now (you still need to reboot and rerun to finish installing WSL2) [y/N]' - if ($cancelReboot.Length -ne 0){ - if ($cancelReboot.Substring(0,1).ToLower() -eq 'y'){ - shutdown /a - } - } -} else { - if (!(Get-Kernel-Updated)) { - Write-Host(" ...WSL kernel update not installed.") - Update-Kernel - } else { - Write-Host(" ...WSL update already installed.") - } - Write-Host("Setting WSL2 as the default...") - wsl --set-default-version 2 - $distro = Select-Distro - Install-Distro($distro) - if ($distro.AppxName.Length -gt 1) { - Start-Process $distro.winpe - } else { - $wslselect = "" - Get-WSLlist | ForEach-Object { - if ($_ -match $distro.Name){ - $wslselect = $_ - } - } - if ($wslselect -ne "") { - wsl -d $wslselect - } else { - Write-Host("Run 'wsl -l' to list WSL Distributions") - Write-Host("Run 'wsl -d ' to start WSL Distro") - } - } -} \ No newline at end of file diff --git a/Tooling/readme.md b/Tooling/readme.md index ca8bd472..700d4d86 100644 --- a/Tooling/readme.md +++ b/Tooling/readme.md @@ -2,9 +2,9 @@ - [Getting Started](./00-GettingStarted) - [Azure Pass](./05-AzurePass) -- [GitHub](./01-Github) +- [Git & GitHub](./01-Git) - [Visual Studio Code](./02-VSCode) - [Markdown](./03-Markdown) - [Azure CLI](./04-CLI) - [Docker and WSL Setup](./08-Docker-WSL) -- [Configure VS Code REST Client Extension](./07-REST-Client) +- [Configure VS Code REST Client Extension](./07-REST-Client) \ No newline at end of file