From c5fe58b016a34a7578acfeecc00fa7781b74f570 Mon Sep 17 00:00:00 2001 From: Evilazaro Alves Date: Thu, 12 Oct 2023 18:48:37 -0400 Subject: [PATCH] ghp --- ...nt-Base-Image-BackEnd-Docker-Template.json | 119 -------- .../backEndEngineerImgTemplate.json | 110 ------- .../computeGallery/configureUbuntuFrontEnd.sh | 4 - .../ARMTemplates/computeGallery/createUser.sh | 31 -- .../eShopBackEnd-Customizations.ps1 | 91 ------ .../eShopBackEnd-InstallWSL.ps1 | 83 ------ .../eShopFrontEnd-Customizations.ps1 | 71 ----- .../frontEndEngineerImgTemplate.json | 112 ------- .../computeGallery/installUtils.sh | 29 -- Deploy/ARMTemplates/computeGallery/test.ps1 | 131 --------- .../computeGallery/updateUbuntu.sh | 10 - .../devBox/devCentertemplate.json | 71 ----- .../aibRoleImageCreation-template.json | 20 -- .../network/networkConnectionTemplate.json | 32 -- Deploy/ARMTemplates/network/parameters.json | 12 - Deploy/ARMTemplates/network/template.json | 32 -- Deploy/Bash/CleanUp.sh | 92 ------ .../computeGallery/createVMImageTemplate.sh | 95 ------ .../computeGallery/deployComputeGallery.sh | 35 --- .../devCenter/createDevBoxDefinition.sh | 53 ---- .../DevBox/devCenter/createDevBoxPools.sh | 58 ---- .../devCenter/createDevBoxforEngineers.sh | 57 ---- .../devCenter/createDevCenterProject.sh | 54 ---- .../Bash/DevBox/devCenter/deployDevCenter.sh | 61 ---- .../Bash/DownloadedTempTemplates/.gitignore | 2 - .../identity/README.MD | 0 .../DownloadedTempTemplates/network/README.MD | 1 - Deploy/Bash/Identity/createIdentity.sh | 46 --- .../createUserAssignedManagedIdentity.sh | 90 ------ Deploy/Bash/Identity/login.sh | 30 -- Deploy/Bash/Identity/registerFeatures.sh | 55 ---- Deploy/Bash/deploy.sh | 275 ------------------ .../Bash/network/createNetWorkConnection.sh | 54 ---- Deploy/Bash/network/deployVnet.sh | 52 ---- Deploy/PowerShell/CleanUp.ps1 | 95 ------ .../DevBox/computeGallery/buildVMImage.ps1 | 81 ------ .../computeGallery/createVMImageTemplate.ps1 | 88 ------ .../computeGallery/deployComputeGallery.ps1 | 30 -- .../devCenter/createDevBoxDefinition.ps1 | 53 ---- .../DevBox/devCenter/createDevBoxPools.ps1 | 55 ---- .../devCenter/createDevBoxforEngineers.ps1 | 56 ---- .../devCenter/createDevCenterProject.ps1 | 54 ---- .../DevBox/devCenter/deployDevCenter.ps1 | 59 ---- .../DownloadedTempTemplates/.gitignore | 2 - Deploy/PowerShell/Identity/createIdentity.ps1 | 50 ---- .../createUserAssignedManagedIdentity.ps1 | 90 ------ Deploy/PowerShell/Identity/login.ps1 | 29 -- .../PowerShell/Identity/registerFeatures.ps1 | 55 ---- Deploy/PowerShell/deploy.ps1 | 112 ------- .../network/createNetWorkConnection.ps1 | 59 ---- Deploy/PowerShell/network/deployVnet.ps1 | 43 --- README.md | 0 CONTRIBUTING.MD => docs/CONTRIBUTING.MD | 0 .../index.md | 0 54 files changed, 3079 deletions(-) delete mode 100644 Deploy/ARMTemplates/computeGallery/Win11-Ent-Base-Image-BackEnd-Docker-Template.json delete mode 100644 Deploy/ARMTemplates/computeGallery/backEndEngineerImgTemplate.json delete mode 100644 Deploy/ARMTemplates/computeGallery/configureUbuntuFrontEnd.sh delete mode 100644 Deploy/ARMTemplates/computeGallery/createUser.sh delete mode 100644 Deploy/ARMTemplates/computeGallery/eShopBackEnd-Customizations.ps1 delete mode 100644 Deploy/ARMTemplates/computeGallery/eShopBackEnd-InstallWSL.ps1 delete mode 100644 Deploy/ARMTemplates/computeGallery/eShopFrontEnd-Customizations.ps1 delete mode 100644 Deploy/ARMTemplates/computeGallery/frontEndEngineerImgTemplate.json delete mode 100644 Deploy/ARMTemplates/computeGallery/installUtils.sh delete mode 100644 Deploy/ARMTemplates/computeGallery/test.ps1 delete mode 100644 Deploy/ARMTemplates/computeGallery/updateUbuntu.sh delete mode 100644 Deploy/ARMTemplates/devBox/devCentertemplate.json delete mode 100644 Deploy/ARMTemplates/identity/aibRoleImageCreation-template.json delete mode 100644 Deploy/ARMTemplates/network/networkConnectionTemplate.json delete mode 100644 Deploy/ARMTemplates/network/parameters.json delete mode 100644 Deploy/ARMTemplates/network/template.json delete mode 100644 Deploy/Bash/CleanUp.sh delete mode 100644 Deploy/Bash/DevBox/computeGallery/createVMImageTemplate.sh delete mode 100644 Deploy/Bash/DevBox/computeGallery/deployComputeGallery.sh delete mode 100644 Deploy/Bash/DevBox/devCenter/createDevBoxDefinition.sh delete mode 100644 Deploy/Bash/DevBox/devCenter/createDevBoxPools.sh delete mode 100644 Deploy/Bash/DevBox/devCenter/createDevBoxforEngineers.sh delete mode 100644 Deploy/Bash/DevBox/devCenter/createDevCenterProject.sh delete mode 100644 Deploy/Bash/DevBox/devCenter/deployDevCenter.sh delete mode 100644 Deploy/Bash/DownloadedTempTemplates/.gitignore delete mode 100644 Deploy/Bash/DownloadedTempTemplates/identity/README.MD delete mode 100644 Deploy/Bash/DownloadedTempTemplates/network/README.MD delete mode 100644 Deploy/Bash/Identity/createIdentity.sh delete mode 100644 Deploy/Bash/Identity/createUserAssignedManagedIdentity.sh delete mode 100644 Deploy/Bash/Identity/login.sh delete mode 100644 Deploy/Bash/Identity/registerFeatures.sh delete mode 100644 Deploy/Bash/deploy.sh delete mode 100644 Deploy/Bash/network/createNetWorkConnection.sh delete mode 100644 Deploy/Bash/network/deployVnet.sh delete mode 100644 Deploy/PowerShell/CleanUp.ps1 delete mode 100644 Deploy/PowerShell/DevBox/computeGallery/buildVMImage.ps1 delete mode 100644 Deploy/PowerShell/DevBox/computeGallery/createVMImageTemplate.ps1 delete mode 100644 Deploy/PowerShell/DevBox/computeGallery/deployComputeGallery.ps1 delete mode 100644 Deploy/PowerShell/DevBox/devCenter/createDevBoxDefinition.ps1 delete mode 100644 Deploy/PowerShell/DevBox/devCenter/createDevBoxPools.ps1 delete mode 100644 Deploy/PowerShell/DevBox/devCenter/createDevBoxforEngineers.ps1 delete mode 100644 Deploy/PowerShell/DevBox/devCenter/createDevCenterProject.ps1 delete mode 100644 Deploy/PowerShell/DevBox/devCenter/deployDevCenter.ps1 delete mode 100644 Deploy/PowerShell/DownloadedTempTemplates/.gitignore delete mode 100644 Deploy/PowerShell/Identity/createIdentity.ps1 delete mode 100644 Deploy/PowerShell/Identity/createUserAssignedManagedIdentity.ps1 delete mode 100644 Deploy/PowerShell/Identity/login.ps1 delete mode 100644 Deploy/PowerShell/Identity/registerFeatures.ps1 delete mode 100644 Deploy/PowerShell/deploy.ps1 delete mode 100644 Deploy/PowerShell/network/createNetWorkConnection.ps1 delete mode 100644 Deploy/PowerShell/network/deployVnet.ps1 delete mode 100644 README.md rename CONTRIBUTING.MD => docs/CONTRIBUTING.MD (100%) rename Deploy/ARMTemplates/computeGallery/Win11-Ent-Base-Image-FrontEnd-Docker-Template.json => docs/index.md (100%) diff --git a/Deploy/ARMTemplates/computeGallery/Win11-Ent-Base-Image-BackEnd-Docker-Template.json b/Deploy/ARMTemplates/computeGallery/Win11-Ent-Base-Image-BackEnd-Docker-Template.json deleted file mode 100644 index 5071d24..0000000 --- a/Deploy/ARMTemplates/computeGallery/Win11-Ent-Base-Image-BackEnd-Docker-Template.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "imgName": { - "defaultValue": "", - "type": "String" - }, - "imageGalleryId": { - "defaultValue": "", - "type": "String" - }, - "userAssignedId": { - "defaultValue": "", - "type": "String" - }, - "location": { - "defaultValue": "", - "type": "String" - } - }, - "variables": {}, - "resources": [ - { - "type": "Microsoft.VirtualMachineImages/imageTemplates", - "apiVersion": "2022-07-01", - "name": "[parameters('imgName')]", - "location": "[parameters('location')]", - "tags": { - "Environment": "Prod", - "Role": "Front-End-Engineer", - "Team": "Engineering", - "businessUnit": "e-Commerce", - "division": "Contoso-Platform", - "offer": "Contoso-DevWorkstation-Service", - "solution": "eShop" - }, - "identity": { - "type": "UserAssigned", - "userAssignedIdentities": { - "[parameters('userAssignedId')]": {} - } - }, - "properties": { - "source": { - "offer": "visualstudioplustools", - "publisher": "microsoftvisualstudio", - "sku": "vs-2022-ent-general-win11-m365-gen2", - "type": "PlatformImage", - "version": "latest" - }, - "customize": [ - { - "type": "PowerShell", - "name": "Installing Ubuntu WSL", - "inline": [ - "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/main/Deploy/ARMTemplates/computeGallery/eShopBackEnd-InstallWSL.ps1'));" - ], - "validExitCodes": [ - 0, - 4294 - ] - }, - { - "type": "WindowsRestart", - "name": "Restarting Windows", - "windowsRestartConfiguration": { - "restartOnlyIfRequired": false, - "restartSetting": "always" - } - }, - { - "type": "PowerShell", - "name": "Installing eShop Dependencies and Customizations", - "inline": [ - "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/main/Deploy/ARMTemplates/computeGallery/eShopBackEnd-Customizations.ps1'));" - ] - }, - { - "type": "WindowsRestart", - "name": "Restarting Windows", - "windowsRestartConfiguration": { - "restartOnlyIfRequired": false, - "restartSetting": "always" - } - } - ], - "distribute": [ - { - "artifactTags": { - "Environment": "Prod", - "Role": "Front-End-Engineer", - "Team": "Engineering", - "businessUnit": "e-Commerce", - "division": "Contoso-Platform", - "offer": "Contoso-DevWorkstation-Service", - "solution": "eShop" - }, - "excludeFromLatest": false, - "galleryImageId": "[concat(parameters('imageGalleryId'), concat('/images/', parameters('imgName'), 'def'))]", - "replicationRegions": [ - "[parameters('location')]" - ], - "runOutputName": "[parameters('imgName')]", - "type": "SharedImage" - } - ], - "buildTimeoutInMinutes": 0, - "vmProfile": { - "vmSize": "Standard_DS2_v2", - "osDiskSizeGB": 128, - "userAssignedIdentities": [ - "[parameters('userAssignedId')]" - ] - } - } - } - ] -} \ No newline at end of file diff --git a/Deploy/ARMTemplates/computeGallery/backEndEngineerImgTemplate.json b/Deploy/ARMTemplates/computeGallery/backEndEngineerImgTemplate.json deleted file mode 100644 index 0b5e9f4..0000000 --- a/Deploy/ARMTemplates/computeGallery/backEndEngineerImgTemplate.json +++ /dev/null @@ -1,110 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "imgName": { - "defaultValue": "", - "type": "String" - }, - "imageGalleryId": { - "defaultValue": "", - "type": "String" - }, - "userAssignedId": { - "defaultValue": "", - "type": "String" - }, - "location": { - "defaultValue": "", - "type": "String" - } - }, - "variables": {}, - "resources": [ - { - "type": "Microsoft.VirtualMachineImages/imageTemplates", - "apiVersion": "2022-07-01", - "name": "[parameters('imgName')]", - "location": "[parameters('location')]", - "tags": { - "Environment": "Prod", - "Role": "Front-End-Engineer", - "Team": "Engineering", - "businessUnit": "e-Commerce", - "division": "Contoso-Platform", - "offer": "Contoso-DevWorkstation-Service", - "solution": "eShop" - }, - "identity": { - "type": "UserAssigned", - "userAssignedIdentities": { - "[parameters('userAssignedId')]": {} - } - }, - "properties": { - "source": { - "offer": "visualstudioplustools", - "publisher": "microsoftvisualstudio", - "sku": "vs-2022-ent-general-win11-m365-gen2", - "type": "PlatformImage", - "version": "latest" - }, - "customize": [ - { - "type": "PowerShell", - "name": "Installing eShop Dependencies and Customizations", - "inline": [ - "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/main/Deploy/ARMTemplates/computeGallery/eShopBackEnd-Customizations.ps1'));" - ] - }, - { - "type": "PowerShell", - "name": "Adding current user to docker-users group", - "inline": [ - "Set-ExecutionPolicy Bypass -Scope Process -Force;", - "# Adds the current user to the docker-users group", - "Write-Host 'Adding current user to docker-users group';", - "Add-LocalGroupMember -Group 'docker-users' -Member 'Everyone';" - ] - }, - { - "type": "WindowsRestart", - "name": "Restarting Windows", - "windowsRestartConfiguration": { - "restartOnlyIfRequired": false, - "restartSetting": "always" - } - } - ], - "distribute": [ - { - "artifactTags": { - "Environment": "Prod", - "Role": "Front-End-Engineer", - "Team": "Engineering", - "businessUnit": "e-Commerce", - "division": "Contoso-Platform", - "offer": "Contoso-DevWorkstation-Service", - "solution": "eShop" - }, - "excludeFromLatest": false, - "galleryImageId": "[concat(parameters('imageGalleryId'), concat('/images/', parameters('imgName'), 'def'))]", - "replicationRegions": [ - "[parameters('location')]" - ], - "runOutputName": "[parameters('imgName')]", - "type": "SharedImage" - } - ], - "buildTimeoutInMinutes": 0, - "vmProfile": { - "vmSize": "Standard_DS2_v2", - "osDiskSizeGB": 128, - "userAssignedIdentities": [ - "[parameters('userAssignedId')]" - ] - } - } - } - ] -} \ No newline at end of file diff --git a/Deploy/ARMTemplates/computeGallery/configureUbuntuFrontEnd.sh b/Deploy/ARMTemplates/computeGallery/configureUbuntuFrontEnd.sh deleted file mode 100644 index 4889588..0000000 --- a/Deploy/ARMTemplates/computeGallery/configureUbuntuFrontEnd.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -export DEBIAN_FRONTEND=noninteractive -echo 'debconf debconf/frontend select Noninteractive' | sudo debconf-set-selections \ No newline at end of file diff --git a/Deploy/ARMTemplates/computeGallery/createUser.sh b/Deploy/ARMTemplates/computeGallery/createUser.sh deleted file mode 100644 index 20596be..0000000 --- a/Deploy/ARMTemplates/computeGallery/createUser.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -set -euo pipefail -DIR_ME=$(realpath $(dirname $0)) -# this script is called by root an must fail if no user is provided -. ${DIR_ME}/installUtils.sh -setUserName ${1-""} -OS_TYPE=${2-"ubuntu"} - -createMainUser () { - verifyUserName - if [[ $(cat /etc/passwd | grep ${USERNAME} | wc -l) == 0 ]]; then - useradd -m -s /bin/bash ${USERNAME} - fi - - # add to sudo group - if [[ "${OS_TYPE}" == "ubuntu" ]]; then - usermod -aG sudo ${USERNAME} - fi - - if [[ ! -d ${HOMEDIR}/Downloads ]]; then - mkdir ${HOMEDIR}/Downloads - chown ${USERNAME}:${USERNAME} ${HOMEDIR}/Downloads - fi - - # ensure no password is set - passwd -d ${USERNAME} -} -createMainUser - -modifyWslConf \ No newline at end of file diff --git a/Deploy/ARMTemplates/computeGallery/eShopBackEnd-Customizations.ps1 b/Deploy/ARMTemplates/computeGallery/eShopBackEnd-Customizations.ps1 deleted file mode 100644 index e27f23f..0000000 --- a/Deploy/ARMTemplates/computeGallery/eShopBackEnd-Customizations.ps1 +++ /dev/null @@ -1,91 +0,0 @@ - -# Set the execution policy -Set-ExecutionPolicy Bypass -Scope Process -Force - -# Define repositories to clone -$repositories = @( - @{ - Url = 'https://github.com/Evilazaro/eShop.git' - Destination = 'c:\eShop' - Description = 'eShopOnContainers Repository' - }, - @{ - Url = 'https://github.com/Evilazaro/eShopAPIM.git' - Destination = 'c:\eShopAPIM' - Description = 'eShopOnContainers APIs Repository' - } -) - -function Clone-Repositories { - param ( - [Parameter(Mandatory = $true)] - [Array]$Repositories - ) - - foreach ($repo in $Repositories) { - Write-Output "Cloning $($repo.Description)" - try { - git clone $repo.Url $repo.Destination - } catch { - throw "Failed to clone $($repo.Description) from $($repo.Url) to $($repo.Destination)" - } - } -} - -function Install-DockerDesktop { - Write-Output "Installing Docker Desktop" - try { - $dockerTempFilePath="c:\DockerTemp" - mkdir $dockerTempFilePath - - $packageArgs = @{ - packageName = 'docker-desktop' - softwareName = 'Docker Desktop' - url = 'https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe' - fileFullPath = "$($dockerTempFilePath)\dockerinstall.exe" - validExitCodes = @(0) - } - - $webClient = New-Object System.Net.WebClient - $webClient.DownloadFile($($packageArgs.url), $($packageArgs.fileFullPath)) - c:\DockerTemp\dockerinstall.exe install --wait --quiet --quiet --accept-license - } catch { - throw "Failed to install Docker Desktop" - } - Write-Output "Docker Desktop installed successfully" -} - -function Install-VSCodeExtensions { - Write-Output "Installing VS Code Extensions" - try { - code --install-extension ms-vscode-remote.remote-wsl --force; - code --install-extension ms-vscode.vscode-node-azure-pack --force; - code --install-extension ms-azuretools.vscode-docker --force; - code --install-extension ms-kubernetes-tools.vscode-aks-tools --force; - code --install-extension ms-azuretools.vscode-apimanagement --force; - code --install-extension VisualStudioOnlineApplicationInsights.application-insights --force; - code --install-extension ms-dotnettools.csdevkit --force; - } catch { - throw "Failed to install VS Code Extensions" - } -} - -function installAzureADModules{ - Write-Output "Installing Azure AD Modules" - try { - Install-Module -Name AzureAD -Force -SkipPublisherCheck - } catch { - throw "Failed to install Azure AD Modules" - } -} - -# Execute Functions -try { - Clone-Repositories -Repositories $repositories - Install-VSCodeExtensions - Install-DockerDesktop - Write-Output "Script completed successfully" -} catch { - Write-Error $_.Exception.Message - throw $_.Exception -} diff --git a/Deploy/ARMTemplates/computeGallery/eShopBackEnd-InstallWSL.ps1 b/Deploy/ARMTemplates/computeGallery/eShopBackEnd-InstallWSL.ps1 deleted file mode 100644 index 9888aca..0000000 --- a/Deploy/ARMTemplates/computeGallery/eShopBackEnd-InstallWSL.ps1 +++ /dev/null @@ -1,83 +0,0 @@ -Set-ExecutionPolicy Bypass -Scope Process -Force; - -Write-Host "Starging WSL Ubuntu installation at $(Get-Date)" - -$automaticInstall = $true -$wslRootPath = "c:\WSL2" -$wslTempPath = $wslRootPath+"\temp" -$wslStagingPath = $wslTempPath+"\staging" -$wslScriptsPth = $wslRootPath+"\scripts" - -Write-Host "Creating Directories" - -mkdir $wslRootPath -mkdir $wslTempPath -mkdir $wslStagingPath -mkdir $wslScriptsPth - -Write-Host "Directories Created" - -$wslIntalled = $false -Write-Host "Checking if WSL is installed" -if (Get-Command wsl.exe -ErrorAction SilentlyContinue) { - $wslIntalled = $true - Write-Host "WSL is Intalled" -} - -if (!$wslIntalled) { - Write-Error "WSL not detected! WSL is needed to install $($packageArgs.softwareName)" - exit 1 -} - - -Write-Host "Downloading Scripts" -Invoke-WebRequest -Uri $("https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/main/Deploy/ARMTemplates/computeGallery/createUser.sh") -OutFile $($wslScriptsPth+"\createUser.sh") -Invoke-WebRequest -Uri $("https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/main/Deploy/ARMTemplates/computeGallery/installUtils.sh") -OutFile $($wslScriptsPth+"\installUtils.sh") -Write-Host "Scripts downloaded to $($wslScriptsPth)" - -if ($automaticInstall) { - $wslName = 'Ubuntu' - $wslInstallationPath = "C:\Users\Default\AppData\Local\WSL2\$wslName" - $wslUsername = "vmadmin" - - - $date = Get-Date - $date = $date.ToLongTimeString() - Write-Host "Installing Ubuntu at $($date)" - wsl --install -d Ubuntu -u root -y - Write-Host "Ubuntu installed succesfuly at $($date)" - - # $date = Get-Date - # $date = $date.ToLongTimeString() - # Write-Host "Ubuntu 22.04 LTS for WSL Installed at $($date)" - - # $date = Get-Date - # $date = $date.ToLongTimeString() - - # Write-Host "Creating Ubuntu User at $($date)" - # wsl -d $wslName -u root bash -ic "/mnt/c/WSL2/scripts/createUser.sh $wslUsername ubuntu" - - # $date = Get-Date - # $date = $date.ToLongTimeString() - # Write-Host "Ubuntu User Created at $($date)" - - # $date = Get-Date - # $date = $date.ToLongTimeString() - # Write-Host "Updating Ubuntu Use at $($date)" - - # wsl -d $wslName -u root bash -ic "/mnt/c/temp/configureUbuntuFrontEnd.sh" - # wsl -d $wslName -u root bash -ic "DEBIAN_FRONTEND=noninteractive /mnt/c/temp/updateUbuntu.sh" - - # $date = Get-Date - # $date = $date.ToLongTimeString() - # Write-Host "Ubuntu Updated at $($date)" - - # Write-Host "Restarting WSL Distro" - # wsl -t $wslName - # write-host "WSL Distro Restarted" - - Write-Host "Finishing WSL Ubuntu installation at $(Get-Date)" -} -else { - Add-AppxPackage $packageArgs.fileFullPath -} \ No newline at end of file diff --git a/Deploy/ARMTemplates/computeGallery/eShopFrontEnd-Customizations.ps1 b/Deploy/ARMTemplates/computeGallery/eShopFrontEnd-Customizations.ps1 deleted file mode 100644 index 4295971..0000000 --- a/Deploy/ARMTemplates/computeGallery/eShopFrontEnd-Customizations.ps1 +++ /dev/null @@ -1,71 +0,0 @@ -<# -.SYNOPSIS -This script clones repositories, installs Docker Desktop, and VS Code Extensions. - -.DESCRIPTION -The script performs the following actions: -- Sets the execution policy to Bypass for the process scope. -- Clones the specified repositories to the specified destinations. -- Installs Docker Desktop using Chocolatey. -- Installs specified VS Code Extensions. -#> - -# Set the execution policy -Set-ExecutionPolicy Bypass -Scope Process -Force - -# Define repositories to clone -$repositories = @( - @{ - Url = 'https://github.com/Evilazaro/eShop.git' - Destination = 'c:\eShop' - Description = 'eShopOnContainers Repository' - }, - @{ - Url = 'https://github.com/Evilazaro/eShopAPIM.git' - Destination = 'c:\eShopAPIM' - Description = 'eShopOnContainers APIs Repository' - } -) - -function Clone-Repositories { - param ( - [Parameter(Mandatory = $true)] - [Array]$Repositories - ) - - foreach ($repo in $Repositories) { - Write-Output "Cloning $($repo.Description)" - try { - git clone $repo.Url $repo.Destination - } catch { - throw "Failed to clone $($repo.Description) from $($repo.Url) to $($repo.Destination)" - } - } -} - -function Install-VSCodeExtensions { - Write-Output "Installing VS Code Extensions" - try { - mkdir c:\VSExtensions - code --extensions-dir c:\VSExtensions - code --install-extension ms-vscode-remote.remote-wsl --force - code --install-extension ms-vscode.vscode-node-azure-pack --force - code --install-extension ms-azuretools.vscode-docker --force - code --install-extension ms-kubernetes-tools.vscode-aks-tools --force - code --install-extension ms-azuretools.vscode-apimanagement --force - code --install-extension VisualStudioOnlineApplicationInsights.application-insights --force - code --install-extension ms-dotnettools.csdevkit --force - } catch { - throw "Failed to install VS Code Extensions" - } -} - -# Execute Functions -try { - Clone-Repositories -Repositories $repositories - Install-VSCodeExtensions - Write-Output "Script completed successfully" -} catch { - Write-Error $_.Exception.Message - throw $_.Exception -} diff --git a/Deploy/ARMTemplates/computeGallery/frontEndEngineerImgTemplate.json b/Deploy/ARMTemplates/computeGallery/frontEndEngineerImgTemplate.json deleted file mode 100644 index 808e394..0000000 --- a/Deploy/ARMTemplates/computeGallery/frontEndEngineerImgTemplate.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "imgName": { - "defaultValue": "", - "type": "String" - }, - "imageGalleryId": { - "defaultValue": "", - "type": "String" - }, - "userAssignedId": { - "defaultValue": "", - "type": "String" - }, - "location": { - "defaultValue": "", - "type": "String" - } - }, - "variables": {}, - "resources": [ - { - "type": "Microsoft.VirtualMachineImages/imageTemplates", - "apiVersion": "2022-07-01", - "name": "[parameters('imgName')]", - "location": "[parameters('location')]", - "tags": { - "Environment": "Prod", - "Role": "Front-End-Engineer", - "Team": "Engineering", - "businessUnit": "e-Commerce", - "division": "Contoso-Platform", - "offer": "Contoso-DevWorkstation-Service", - "solution": "eShop" - }, - "identity": { - "type": "UserAssigned", - "userAssignedIdentities": { - "[parameters('userAssignedId')]": {} - } - }, - "properties": { - "source": { - "offer": "windowsplustools", - "publisher": "microsoftvisualstudio", - "sku": "base-win11-gen2", - "type": "PlatformImage", - "version": "latest" - }, - "customize": [ - { - "type": "WindowsUpdate", - "name": "Installing Windows Updates", - "windowsUpdateProvisioningConfiguration": { - "includedUpdateClassifications": [ - "Critical", - "Security", - "UpdateRollup" - ], - "rebootSetting": "ifRequired" - } - }, - { - "type": "WindowsRestart", - "name": "Restarting Windows", - "windowsRestartConfiguration": { - "restartOnlyIfRequired": false, - "restartSetting": "always" - } - }, - { - "type": "PowerShell", - "name": "Installing eShop Dependencies and Customizations", - "inline": [ - "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/main/Deploy/ARMTemplates/computeGallery/eShopFrontEnd-Customizations.ps1'));" - ] - } - ], - "distribute": [ - { - "artifactTags": { - "Environment": "Prod", - "Role": "Front-End-Engineer", - "Team": "Engineering", - "businessUnit": "e-Commerce", - "division": "Contoso-Platform", - "offer": "Contoso-DevWorkstation-Service", - "solution": "eShop" - }, - "excludeFromLatest": false, - "galleryImageId": "[concat(parameters('imageGalleryId'), concat('/images/', parameters('imgName'), 'def'))]", - "replicationRegions": [ - "[parameters('location')]" - ], - "runOutputName": "[parameters('imgName')]", - "type": "SharedImage" - } - ], - "buildTimeoutInMinutes": 0, - "vmProfile": { - "vmSize": "Standard_DS2_v2", - "osDiskSizeGB": 128, - "userAssignedIdentities": [ - "[parameters('userAssignedId')]" - ] - } - } - } - ] -} \ No newline at end of file diff --git a/Deploy/ARMTemplates/computeGallery/installUtils.sh b/Deploy/ARMTemplates/computeGallery/installUtils.sh deleted file mode 100644 index 1babce1..0000000 --- a/Deploy/ARMTemplates/computeGallery/installUtils.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -euo pipefail -DIR_INSTALL_UTILS=$(realpath $( dirname ${BASH_SOURCE[0]:-$0} ) ) -USERNAME="" -HOMEDIR="" - -setUserName () { - USERNAME=${1-""} - verifyUserName -} - -verifyUserName () { - if [[ ${USERNAME} == "" ]]; then - echo "Please pass a user name" - exit 1 - elif [[ ${USERNAME} == "root" ]]; then - HOMEDIR="/root" - else - HOMEDIR="/home/${USERNAME}" - fi -} - -modifyWslConf () { - verifyUserName - sudo touch /etc/wsl.conf - sudo echo "[user]" >> /etc/wsl.conf - sudo echo "default=${USERNAME}" >> /etc/wsl.conf -} \ No newline at end of file diff --git a/Deploy/ARMTemplates/computeGallery/test.ps1 b/Deploy/ARMTemplates/computeGallery/test.ps1 deleted file mode 100644 index 24fee8f..0000000 --- a/Deploy/ARMTemplates/computeGallery/test.ps1 +++ /dev/null @@ -1,131 +0,0 @@ -cls -Set-ExecutionPolicy Bypass -Scope Process -Force; - -wsl --unregister Ubuntu - -$ErrorActionPreference = 'Stop' - -$automaticInstall = $true -$wslRootPath = "c:\WSL2" -$wslTempPath = $wslRootPath+"\temp" -$wslStagingPath = $wslTempPath+"\staging" -$wslScriptsPth = $wslRootPath+"\scripts" - -Write-Host "Creating Directories" - -mkdir $wslRootPath -mkdir $wslTempPath -mkdir $wslStagingPath -mkdir $wslScriptsPth - -$packageArgs = @{ - packageName = 'wsl-ubuntu-2204' - softwareName = 'Ubuntu 22.04 LTS for WSL' - checksum = 'c5028547edfe72be8f7d44ef52cee5aacaf9b1ae1ed4f7e39b94dae3cf286bc2' - checksumType = 'sha256' - url = 'https://aka.ms/wslubuntu2204' - fileFullPath = "$wslTempPath\ubuntu2204.appx" - validExitCodes = @(0) -} - -$wslIntalled = $false -Write-Host "Checking if WSL is installed" -if (Get-Command wsl.exe -ErrorAction SilentlyContinue) { - $wslIntalled = $true - Write-Host "WSL is Intalled" -} - -if (!$wslIntalled) { - Write-Error "WSL not detected! WSL is needed to install $($packageArgs.softwareName)" - exit 1 -} - -$date = Get-Date -$date = $date.ToLongTimeString() -Write-Host "Downloading $($packageArgs.softwareName) at $($date)" - -# Download Docker Desktop Installer -$webClient = New-Object System.Net.WebClient -$webClient.DownloadFile($($packageArgs.url), $($packageArgs.fileFullPath)) - -$date = Get-Date -$date = $date.ToLongTimeString() - -Write-Host "$($packageArgs.softwareName) downloaded to $($packageArgs.fileFullPath) at $($date)" - -Write-Host "Downloading Scripts" -Invoke-WebRequest -Uri $("https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/main/Deploy/ARMTemplates/computeGallery/createUser.sh") -OutFile $($wslScriptsPth+"\createUser.sh") -Invoke-WebRequest -Uri $("https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/main/Deploy/ARMTemplates/computeGallery/installUtils.sh") -OutFile $($wslScriptsPth+"\installUtils.sh") -Write-Host "Scripts downloaded to $($wslScriptsPth)" - -if ($automaticInstall) { - $wslName = 'Ubuntu' - $wslInstallationPath = "C:\Users\Default\AppData\Local\WSL2\$wslName" - $wslUsername = "vmadmin" - - # create staging directory if it does not exists - if (-Not (Test-Path -Path $wslTempPath\staging)) { $dir = mkdir $wslTempPath\staging } - - Move-Item $wslTempPath\ubuntu2204.appx $wslTempPath\staging\$wslName-Temp.zip -Force - - Expand-Archive $wslTempPath\staging\$wslName-Temp.zip $wslTempPath\staging\$wslName-Temp -Force - - Move-Item $wslTempPath\staging\$wslName-Temp\Ubuntu_2204.1.7.0_x64.appx $wslTempPath\staging\$wslName.zip -Force - - Expand-Archive $wslTempPath\staging\$wslName.zip $wslTempPath\staging\$wslName -Force - - if (-Not (Test-Path -Path $wslInstallationPath)) { - $date = Get-Date - $date = $date.ToLongTimeString() - Write-Host "Creating Ubuntu Directory at $($date)" - mkdir $wslInstallationPath - $date = Get-Date - $date = $date.ToLongTimeString() - Write-Host "Ubuntu Directory created succesfully at $($date)" - } - - $date = Get-Date - $date = $date.ToLongTimeString() - Write-Host "Importing/Installing WSL at $($date)" - wsl --import $wslName $wslInstallationPath $wslTempPath\staging\$wslName\install.tar.gz - Write-Host "Ubuntu Imported succesfuly at $($date)" - - Write-Host "Moving Ubuntu to staging directory at $($date)" - Move-Item $wslTempPath\staging\$wslName-Temp.zip $wslTempPath\ubuntu2204.appx -Force - Write-Host "Ubuntu Moved to statgin directory succesfully at $($date)" - - # Write-Host "Deleting Ubuntu from staging directory at $($date)" - # Remove-Item -r $wslTempPath\staging\ -Force - # Write-Host "Ubuntu deleted succesfully from staging directory at $($date)" - - $date = Get-Date - $date = $date.ToLongTimeString() - Write-Host "Ubuntu 22.04 LTS for WSL Installed at $($date)" - - $date = Get-Date - $date = $date.ToLongTimeString() - - Write-Host "Creating Ubuntu User at $($date)" - #wsl -d $wslName -u root bash -ic "/mnt/c/WSL2/scripts/createUser.sh $wslUsername ubuntu" - - $date = Get-Date - $date = $date.ToLongTimeString() - Write-Host "Ubuntu User Created at $($date)" - - $date = Get-Date - $date = $date.ToLongTimeString() - Write-Host "Updating Ubuntu Use at $($date)" - - #wsl -d $wslName -u root bash -ic "/mnt/c/temp/configureUbuntuFrontEnd.sh" - #wsl -d $wslName -u root bash -ic "DEBIAN_FRONTEND=noninteractive /mnt/c/temp/updateUbuntu.sh" - - $date = Get-Date - $date = $date.ToLongTimeString() - Write-Host "Ubuntu Updated at $($date)" - - Write-Host "Restarting WSL Distro" - wsl -t $wslName -} -else { - Add-AppxPackage $packageArgs.fileFullPath -} \ No newline at end of file diff --git a/Deploy/ARMTemplates/computeGallery/updateUbuntu.sh b/Deploy/ARMTemplates/computeGallery/updateUbuntu.sh deleted file mode 100644 index da786f7..0000000 --- a/Deploy/ARMTemplates/computeGallery/updateUbuntu.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -function updateUbuntu -{ - sudo apt-get update && sudo apt-get upgrade -y -} - -updateUbuntu \ No newline at end of file diff --git a/Deploy/ARMTemplates/devBox/devCentertemplate.json b/Deploy/ARMTemplates/devBox/devCentertemplate.json deleted file mode 100644 index 7fb83f3..0000000 --- a/Deploy/ARMTemplates/devBox/devCentertemplate.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "devCenterName": { - "defaultValue": "", - "type": "String" - }, - "networkConnectionId": { - "defaultValue": "", - "type": "String" - }, - "computeGalleryId": { - "defaultValue": "", - "type": "String" - }, - "location": { - "defaultValue": "", - "type": "String" - }, - "networkConnectionName": { - "defaultValue": "", - "type": "String" - }, - "userIdentityId": { - "defaultValue": "", - "type": "String" - }, - "computeGalleryImageName": { - "defaultValue": "", - "type": "String" - } - }, - "variables": {}, - "resources": [ - { - "type": "Microsoft.DevCenter/devcenters", - "apiVersion": "2023-04-01", - "name": "[parameters('devCenterName')]", - "location": "[parameters('location')]", - "identity": { - "type": "UserAssigned", - "userAssignedIdentities": { - "[parameters('userIdentityId')]": {} - } - } - }, - { - "type": "Microsoft.DevCenter/devcenters/attachednetworks", - "apiVersion": "2023-04-01", - "name": "[concat(parameters('devCenterName'), '/', parameters('networkConnectionName'))]", - "dependsOn": [ - "[resourceId('Microsoft.DevCenter/devcenters', parameters('devCenterName'))]" - ], - "properties": { - "networkConnectionId": "[parameters('networkConnectionId')]" - } - }, - { - "type": "Microsoft.DevCenter/devcenters/galleries", - "apiVersion": "2023-04-01", - "name": "[concat(parameters('devCenterName'), '/', parameters('computeGalleryImageName'))]", - "dependsOn": [ - "[resourceId('Microsoft.DevCenter/devcenters', parameters('devCenterName'))]" - ], - "properties": { - "galleryResourceId": "[parameters('computeGalleryId')]" - } - } - ] -} \ No newline at end of file diff --git a/Deploy/ARMTemplates/identity/aibRoleImageCreation-template.json b/Deploy/ARMTemplates/identity/aibRoleImageCreation-template.json deleted file mode 100644 index 93449f6..0000000 --- a/Deploy/ARMTemplates/identity/aibRoleImageCreation-template.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "Name": "", - "IsCustom": true, - "Description": "Image Builder access to create resources for the image build, you should delete or split out as appropriate", - "Actions": [ - "Microsoft.Compute/galleries/read", - "Microsoft.Compute/galleries/images/read", - "Microsoft.Compute/galleries/images/versions/read", - "Microsoft.Compute/galleries/images/versions/write", - "Microsoft.Compute/images/write", - "Microsoft.Compute/images/read", - "Microsoft.Compute/images/delete" - ], - "NotActions": [ - - ], - "AssignableScopes": [ - "/subscriptions/" - ] - } diff --git a/Deploy/ARMTemplates/network/networkConnectionTemplate.json b/Deploy/ARMTemplates/network/networkConnectionTemplate.json deleted file mode 100644 index 799a153..0000000 --- a/Deploy/ARMTemplates/network/networkConnectionTemplate.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "defaultValue": "", - "type": "String" - }, - "vnetId": { - "defaultValue": "", - "type": "String" - }, - "location": { - "defaultValue": "", - "type": "String" - } - }, - "variables": {}, - "resources": [ - { - "type": "Microsoft.DevCenter/networkconnections", - "apiVersion": "2023-04-01", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "properties": { - "domainJoinType": "AzureADJoin", - "subnetId": "[parameters('vnetId')]", - "networkingResourceGroupName": "[concat('NI_', parameters('name'), '_', parameters('location'))]" - } - } - ] -} \ No newline at end of file diff --git a/Deploy/ARMTemplates/network/parameters.json b/Deploy/ARMTemplates/network/parameters.json deleted file mode 100644 index 2072f0a..0000000 --- a/Deploy/ARMTemplates/network/parameters.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "networkconnections_dasfasdfasf_name": { - "value": null - }, - "virtualNetworks_eShop_DevBox_VNet_externalid": { - "value": null - } - } -} \ No newline at end of file diff --git a/Deploy/ARMTemplates/network/template.json b/Deploy/ARMTemplates/network/template.json deleted file mode 100644 index 702b031..0000000 --- a/Deploy/ARMTemplates/network/template.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "name": { - "defaultValue": "", - "type": "String" - }, - "vnetId": { - "defaultValue": "", - "type": "String" - }, - "location": { - "defaultValue": "", - "type": "String" - } - }, - "variables": {}, - "resources": [ - { - "type": "Microsoft.DevCenter/networkconnections", - "apiVersion": "2023-04-01", - "name": "[parameters('name')]", - "location": "[parameters('location')]", - "properties": { - "domainJoinType": "AzureADJoin", - "subnetId": "[concat(parameters('vnetId'), '/subnets/eShop-SubNet')]", - "networkingResourceGroupName": "[concat('NI_', parameters('name'), '_', parameters('location'))]" - } - } - ] -} \ No newline at end of file diff --git a/Deploy/Bash/CleanUp.sh b/Deploy/Bash/CleanUp.sh deleted file mode 100644 index a6f6e10..0000000 --- a/Deploy/Bash/CleanUp.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -clear - -# Declaring Variables - -# Resources Organization -subscriptionId=$(az account show --query id --output tsv) -devBoxResourceGroupName='ContosoFabric-DevBox-RG' -imageGalleryResourceGroupName='ContosoFabric-ImageGallery-RG' -identityResourceGroupName='ContosoFabric-Identity-DevBox-RG' -networkResourceGroupName='eShop-Network-Connectivity-RG' -managementResourceGroupName='ContosoFabric-DevBox-Management-RG' -networkWatcherResourceGroupName='NetworkWatcherRG' -location='WestUS3' - -# Identity -identityName='ContosoFabricDevBoxImgBldId' -customRoleName='ContosoFabricBuilderRole' - -# Function to delete a resource group -function deleteResourceGroup() { - local resourceGroupName="$1" - - output=$(az group exists --name "$resourceGroupName") - - if $output; then - echo "Deleting resource group: $resourceGroupName..." - az group delete --name "$resourceGroupName" --yes --no-wait - echo "Resource group $resourceGroupName deletion initiated." - else - echo "Resource group $resourceGroupName does not exist. Skipping deletion." - fi -} - -# Function to remove a role -function removeRole() { - local customRoleName=$1 - - output=$(az role definition list --name "$customRoleName") - - if [[ -z "$output" || "$output" == "[]" ]]; then - echo "'$customRoleName' role does not exist. Skipping deletion." - else - echo "Deleting the '$customRoleName' role..." - az role definition delete --name "$customRoleName" - echo "'$customRoleName' role successfully deleted." - fi -} - -# Function to remove a role assignment -function removeRoleAssignment() { - local roleId=$1 - local subscriptionId=$2 - - echo "Checking the role assignments for the identity..." - - if [[ -z "$roleId" ]]; then - echo "Role not defined. Skipping role assignment deletion." - return - fi - - output=$(az role assignment list --role "$roleId" --scope /subscriptions/"$subscriptionId") - - if [[ -z "$output" || "$output" == "[]" ]]; then - echo "'$roleId' role assignment does not exist. Skipping deletion." - else - echo "Removing '$roleId' role assignment from the identity..." - az role assignment delete --role "$roleId" --scope /subscriptions/"$subscriptionId" - echo "'$roleId' role assignment successfully removed." - fi -} - -# Deleting role assignments and role definitions -for roleName in 'Owner' 'Managed Identity Operator' 'Reader' 'DevCenter Dev Box User' "$customRoleName"; do - echo "Getting the role ID for '$roleName'..." - roleId=$(az role definition list --name "$roleName" --query [].name --output tsv) - - removeRoleAssignment "$roleId" "$subscriptionId" -done - -removeRole "$customRoleName" - -# Deleting resource groups -deleteResourceGroup "$devBoxResourceGroupName" -deleteResourceGroup "$imageGalleryResourceGroupName" -deleteResourceGroup "$identityResourceGroupName" -deleteResourceGroup "$networkResourceGroupName" -deleteResourceGroup "$managementResourceGroupName" -deleteResourceGroup "$networkWatcherResourceGroupName" -deleteResourceGroup "Default-ActivityLogAlerts" -deleteResourceGroup "DefaultResourceGroup-WUS2" \ No newline at end of file diff --git a/Deploy/Bash/DevBox/computeGallery/createVMImageTemplate.sh b/Deploy/Bash/DevBox/computeGallery/createVMImageTemplate.sh deleted file mode 100644 index 59c77ef..0000000 --- a/Deploy/Bash/DevBox/computeGallery/createVMImageTemplate.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/bash - -# This script creates an image definition in a shared image gallery, retrieves the IDs of image gallery and user-assigned identity, -# creates a deployment group and invokes an action on a resource. - -# Ensure the script exits when a command fails -set -e - -# Usage instructions for the script if not all parameters are provided -if [[ $# -lt 12 ]]; then - echo "Usage: $0 " - exit 1 -fi - -# Assign command-line arguments to variables with descriptive names -outputFile="$1" -subscriptionID="$2" -resourceGroupName="$3" -location="$4" -imageName="$5" -identityName="$6" -imageFileUri="$7" -galleryName="$8" -offer="$9" -imgSKU="${10}" -publisher="${11}" -identityResourceGroupName="${12}" - -# Construct image definition name -imageDefName="${imageName}Def" - -# Define image features -features="SecurityType=TrustedLaunch IsHibernateSupported=true" - -# Log the step being executed -echo "Creating image definition..." - -# Create image definition in a shared image gallery -az sig image-definition create \ - --resource-group "${resourceGroupName}" \ - --gallery-name "${galleryName}" \ - --gallery-image-definition "${imageDefName}" \ - --os-type Windows \ - --publisher "${publisher}" \ - --offer "${offer}" \ - --sku "${imgSKU}" \ - --os-state generalized \ - --hyper-v-generation V2 \ - --features "${features}" \ - --location "${location}" \ - --tags "division=Contoso-Platform" \ - "Environment=Prod" \ - "offer=Contoso-DevWorkstation-Service" \ - "Team=Engineering" \ - "solution=eShop" \ - "businessUnit=e-Commerce" - -# Log the step being executed -echo "Retrieving the ID of the image gallery..." - -# Retrieve the ID of the image gallery -imageGalleryId=$(az sig show --resource-group "${resourceGroupName}" \ - --gallery-name "${galleryName}" --query id --output tsv) - -# Log the step being executed -echo "Retrieving the ID of the user-assigned identity..." - -# Retrieve the ID of the user-assigned identity -userAssignedId=$(az identity show --resource-group "${identityResourceGroupName}" \ - --name "${identityName}" --query id --output tsv) - -# Log the step being executed -echo "Creating a deployment group..." - -# Create a deployment group -az deployment group create \ - --resource-group "${resourceGroupName}" \ - --template-uri "${imageFileUri}" \ - --parameters imgName="${imageName}" \ - imageGalleryId="${imageGalleryId}" \ - userAssignedId="${userAssignedId}" \ - location="${location}" - -# Log the step being executed -echo "Invoking an action on the resource..." - -# Invoke an action on the resource -az resource invoke-action \ - --ids $(az resource show --name "${imageName}" --resource-group "${resourceGroupName}" --resource-type "Microsoft.VirtualMachineImages/imageTemplates" --query id --output tsv) \ - --action "Run" \ - --request-body '{}' \ - --query properties.outputs - -# Log the successful execution of the script -echo "Script executed successfully." diff --git a/Deploy/Bash/DevBox/computeGallery/deployComputeGallery.sh b/Deploy/Bash/DevBox/computeGallery/deployComputeGallery.sh deleted file mode 100644 index 0dfe9fb..0000000 --- a/Deploy/Bash/DevBox/computeGallery/deployComputeGallery.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# Exit immediately if a command exits with a non-zero status, and treat unset variables as an error. -set -euo pipefail - -# Check if the correct number of arguments are passed, if not, exit with an error message -if [ "$#" -ne 3 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Assigning input arguments to descriptive variable names for better clarity and readability -computeGalleryName="$1" -location="$2" -galleryResourceGroupName="$3" - -# Informing the user about the start of resource creation -echo "Initializing the creation of a Shared Image Gallery named '$computeGalleryName' in resource group '$galleryResourceGroupName' located in '$location'." - -# Execute the Azure command to create the resource, with tags for better resource categorization and management -# Echoing the command before running it for better user awareness -echo "Executing Azure CLI command to create the Shared Image Gallery..." -az sig create \ - --gallery-name "$computeGalleryName" \ - --resource-group "$galleryResourceGroupName" \ - --location "$location" \ - --tags "Division=Contoso-Platform" \ - "Environment=Prod" \ - "Offer=Contoso-DevWorkstation-Service" \ - "Team=Engineering" \ - "Solution=eShop" \ - "BusinessUnit=e-Commerce" - -# Confirming the successful creation of the resource -echo "Shared Image Gallery '$computeGalleryName' successfully created in resource group '$galleryResourceGroupName' located in '$location'." diff --git a/Deploy/Bash/DevBox/devCenter/createDevBoxDefinition.sh b/Deploy/Bash/DevBox/devCenter/createDevBoxDefinition.sh deleted file mode 100644 index 43e9d03..0000000 --- a/Deploy/Bash/DevBox/devCenter/createDevBoxDefinition.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# Best Practices Revised Bash Script - -# Assigning input arguments to variables with more descriptive, camelCase names -subscriptionId="$1" # subscription ID -location="$2" # location -devBoxResourceGroupName="$3" # resource group name -devCenterName="$4" # development center name -galleryName="$5" # gallery name -imageName="$6" # image name -networkConnectionName="$7" # network connection name - -# Inform the user about the initialization step -echo "Initializing script with subscriptionId: $subscriptionId, location: $location, devBoxResourceGroupName: $devBoxResourceGroupName, devCenterName: $devCenterName, galleryName: $galleryName, and imageName: $imageName." - -# Construct necessary variables with camelCase naming conventions -imageReferenceId="/subscriptions/$subscriptionId/resourceGroups/$devBoxResourceGroupName/providers/Microsoft.DevCenter/devcenters/$devCenterName/galleries/${galleryName}/images/${imageName}Def/versions/1.0.0" -devBoxDefinitionName="devBox-$imageName" -projectName="eShop" -poolName="$imageName-pool" -devBoxName="$imageName-devbox" - -# Echo the constructed variables -echo "Constructed variables: -imageReferenceId: $imageReferenceId -devBoxDefinitionName: $devBoxDefinitionName -networkConnectionName: $networkConnectionName -projectName: $projectName -poolName: $poolName -devBoxName: $devBoxName -imageName: $imageName" - -# Creating a DevBox definition with camelCase variable names and added echo for step tracking -echo "Creating DevBox definition..." -az devcenter admin devbox-definition create --location "$location" \ - --image-reference id="$imageReferenceId" \ - --os-storage-type "ssd_256gb" \ - --sku name="general_i_8c32gb256ssd_v2" \ - --name "$devBoxDefinitionName" \ - --dev-center-name "$devCenterName" \ - --resource-group "$devBoxResourceGroupName" - -echo "DevBox definition created successfully." - -# Creating DevBox Pools with added echo for step tracking -echo "Creating DevBox Pools..." -./devBox/devCenter/createDevBoxPools.sh "$location" "$devBoxDefinitionName" "$networkConnectionName" "$poolName" "$projectName" "$devBoxResourceGroupName" -echo "DevBox Pools created successfully." - -# Creating DevBox for Engineers with added echo for step tracking -echo "Creating DevBox for Engineers..." -./devBox/devCenter/createDevBoxforEngineers.sh "$poolName" "$devBoxName" "$devCenterName" "$projectName" -echo "DevBox for Engineers created successfully." diff --git a/Deploy/Bash/DevBox/devCenter/createDevBoxPools.sh b/Deploy/Bash/DevBox/devCenter/createDevBoxPools.sh deleted file mode 100644 index b67c65b..0000000 --- a/Deploy/Bash/DevBox/devCenter/createDevBoxPools.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -# Define the usage of the script to inform users about expected parameters -usage() { - echo "Usage: $0 " -} - -# Validate the number of arguments passed to the script -if [ "$#" -ne 6 ]; then - echo "Error: Incorrect number of arguments" - usage - exit 1 -fi - -# Assign arguments to variables with meaningful names in camelCase -location="$1" -devBoxDefinitionName="$2" -networkConnectionName="$3" -poolName="$4" -projectName="$5" -devBoxResourceGroupName="$6" - -# Function to create a DevCenter admin pool -function createDevCenterAdminPool() { - echo "Creating DevCenter admin pool with the following parameters:" - echo "Location: $location" - echo "DevBox Definition Name: $devBoxDefinitionName" - echo "Network Connection Name: $networkConnectionName" - echo "Pool Name: $poolName" - echo "Project Name: $projectName" - echo "Resource Group: $devBoxResourceGroupName" - - az devcenter admin pool create \ - --location "$location" \ - --devbox-definition-name "$devBoxDefinitionName" \ - --network-connection-name "$networkConnectionName" \ - --pool-name "$poolName" \ - --project-name "$projectName" \ - --resource-group "$devBoxResourceGroupName" \ - --local-administrator "Enabled" \ - --tags "Division=Contoso-Platform" \ - "Environment=Prod" \ - "Offer=Contoso-DevWorkstation-Service" \ - "Team=Engineering" \ - "Solution=eShop" \ - "BusinessUnit=e-Commerce" - - # Check the exit status of the last command and echo a message accordingly - if [ "$?" -eq 0 ]; then - echo "DevCenter admin pool created successfully." - else - echo "Failed to create DevCenter admin pool. Please check the parameters and try again." - exit 1 - fi -} - -# Call the function to create a DevCenter admin pool -createDevCenterAdminPool diff --git a/Deploy/Bash/DevBox/devCenter/createDevBoxforEngineers.sh b/Deploy/Bash/DevBox/devCenter/createDevBoxforEngineers.sh deleted file mode 100644 index d535ee6..0000000 --- a/Deploy/Bash/DevBox/devCenter/createDevBoxforEngineers.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Check if the correct number of arguments has been provided -if [ "$#" -ne 4 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Assign command line arguments to variables with meaningful names -poolName="$1" -devBoxName="$2" -devCenterName="$3" -projectName="$4" - -# Inform the user about the values received -echo "Creating Dev Box with:" -echo "Pool Name: $poolName" -echo "Dev Box Name: $devBoxName" -echo "Dev Center Name: $devCenterName" -echo "Project Name: $projectName" - -# Obtain the current Azure logged user name and ID -echo "Retrieving current Azure logged user information..." -currentUserName=$(az account show --query user.name -o tsv) - -if [ -z "$currentUserName" ]; then - echo "Error: Couldn't retrieve the current Azure user name. Exiting." - exit 1 -fi - -echo "Current Azure User Name: $currentUserName" - -currentAzureLoggedUserID=$(az ad user show --id "$currentUserName" --query id -o tsv) - -if [ -z "$currentAzureLoggedUserID" ]; then - echo "Error: Couldn't retrieve the current Azure user ID. Exiting." - exit 1 -fi - -echo "Current Azure User ID: $currentAzureLoggedUserID" - -# Create a dev box with specified parameters -echo "Creating Dev Box..." -az devcenter dev dev-box create \ - --pool-name "$poolName" \ - --name "$devBoxName" \ - --dev-center-name "$devCenterName" \ - --project-name "$projectName" \ - --user-id "$currentAzureLoggedUserID" - -# Check if the dev box creation was successful -if [ "$?" -eq 0 ]; then - echo "Dev Box '$devBoxName' has been created successfully!" -else - echo "Error: Dev Box creation failed." - exit 1 -fi diff --git a/Deploy/Bash/DevBox/devCenter/createDevCenterProject.sh b/Deploy/Bash/DevBox/devCenter/createDevCenterProject.sh deleted file mode 100644 index 140900f..0000000 --- a/Deploy/Bash/DevBox/devCenter/createDevCenterProject.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -# This script creates a devcenter admin project in Azure, applying several tags. - -# Define variables -location="$1" -subscriptionId="$2" -devBoxResourceGroupName="$3" -devCenterName="$4" -description="Sample .NET Core reference application, powered by Microsoft" -projectName="eShop" -maxDevBoxesPerUser="10" - -# Print usage information if not enough arguments are provided -if [ "$#" -ne 4 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Construct the dev-center-id -devCenterId="/subscriptions/$subscriptionId/resourceGroups/$devBoxResourceGroupName/providers/Microsoft.DevCenter/devcenters/$devCenterName" - -# Inform the user about the action to be performed -echo "Creating a new devcenter admin project in Azure..." -echo "Location: $location" -echo "Subscription ID: $subscriptionId" -echo "Resource Group Name: $devBoxResourceGroupName" -echo "Dev Center Name: $devCenterName" -echo "Description: $description" -echo "Project Name: $projectName" -echo "Max Dev Boxes Per User: $maxDevBoxesPerUser" - -# Run the Azure CLI command to create a devcenter admin project -az devcenter admin project create \ - --location "$location" \ - --description "$description" \ - --dev-center-id "$devCenterId" \ - --name "$projectName" \ - --resource-group "$devBoxResourceGroupName" \ - --max-dev-boxes-per-user "$maxDevBoxesPerUser" \ - --tags "division=Contoso-Platform" \ - "Environment=Prod" \ - "offer=Contoso-DevWorkstation-Service" \ - "Team=Engineering" \ - "solution=eShop" \ - "businessUnit=e-Commerce" - -# Check the status of the last command run and inform the user -if [ $? -eq 0 ]; then - echo "Devcenter admin project '$projectName' has been created successfully!" -else - echo "Failed to create devcenter admin project '$projectName'." >&2 - exit 2 -fi diff --git a/Deploy/Bash/DevBox/devCenter/deployDevCenter.sh b/Deploy/Bash/DevBox/devCenter/deployDevCenter.sh deleted file mode 100644 index f942ddd..0000000 --- a/Deploy/Bash/DevBox/devCenter/deployDevCenter.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -# Exit script if any command fails -set -e - -# Validate number of arguments -if [ "$#" -ne 9 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Assign arguments to variables -devCenterName="$1" -networkConnectionName="$2" -imageGalleryName="$3" -location="$4" -identityName="$5" -devBoxResourceGroupName="$6" -networkResourceGroupName="$7" -identityResourceGroupName="$8" -imageGalleryResourceGroupName="$9" - -echo "Starting to deploy Dev Center with the following parameters:" -echo "Dev Center Name: $devCenterName" -echo "Network Connection Name: $networkConnectionName" -echo "Image Gallery Name: $imageGalleryName" -echo "Location: $location" -echo "Identity Name: $identityName" -echo "DevBox Resource Group Name: $devBoxResourceGroupName" -echo "Network Resource Group Name: $networkResourceGroupName" -echo "Identity Resource Group Name: $identityResourceGroupName" -echo "Image Gallery Resource Group Name: $imageGalleryResourceGroupName" - -# Define other constants -branch="main" -templateFileUri="https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/$branch/Deploy/ARMTemplates/devBox/devCentertemplate.json" - -echo "Fetching network connection id..." -networkConnectionId=$(az devcenter admin network-connection list --resource-group $networkResourceGroupName --query [0].id --output tsv) - -echo "Fetching compute gallery id..." -computeGalleryId=$(az sig show --resource-group $imageGalleryResourceGroupName --gallery-name $imageGalleryName --query id --output tsv) - -echo "Fetching user identity id..." -userIdentityId=$(az identity show --resource-group $identityResourceGroupName --name $identityName --query id --output tsv) - -echo "Creating deployment group..." -az deployment group create \ - --name "$devCenterName" \ - --resource-group "$devBoxResourceGroupName" \ - --template-uri $templateFileUri \ - --parameters \ - devCenterName="$devCenterName" \ - networkConnectionId="$networkConnectionId" \ - computeGalleryId="$computeGalleryId" \ - location="$location" \ - networkConnectionName="$networkConnectionName" \ - userIdentityId="$userIdentityId" \ - computeGalleryImageName="$imageGalleryName" - -echo "Deployment of Dev Center is complete." diff --git a/Deploy/Bash/DownloadedTempTemplates/.gitignore b/Deploy/Bash/DownloadedTempTemplates/.gitignore deleted file mode 100644 index e22d156..0000000 --- a/Deploy/Bash/DownloadedTempTemplates/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# ignore all json files -*.json \ No newline at end of file diff --git a/Deploy/Bash/DownloadedTempTemplates/identity/README.MD b/Deploy/Bash/DownloadedTempTemplates/identity/README.MD deleted file mode 100644 index e69de29..0000000 diff --git a/Deploy/Bash/DownloadedTempTemplates/network/README.MD b/Deploy/Bash/DownloadedTempTemplates/network/README.MD deleted file mode 100644 index af219b0..0000000 --- a/Deploy/Bash/DownloadedTempTemplates/network/README.MD +++ /dev/null @@ -1 +0,0 @@ -CD .. \ No newline at end of file diff --git a/Deploy/Bash/Identity/createIdentity.sh b/Deploy/Bash/Identity/createIdentity.sh deleted file mode 100644 index 2296ad6..0000000 --- a/Deploy/Bash/Identity/createIdentity.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# This script creates an identity on Microsoft Azure. -# It expects three parameters in the exact order: -# 1. Resource Group Name -# 2. Location -# 3. Identity Name - -# Function to display usage information -function usage() { - echo "Usage: $0 " - echo "Example: $0 myResourceGroup EastUS myIdentity" - exit 1 -} - -# Check if the correct number of arguments is provided, if not, display usage information and exit. -if [ "$#" -ne 3 ]; then - echo "Error: Invalid number of arguments." - usage -fi - -# Assigning passed arguments to variables and echoing the assignments. -resourceGroupName="$1" -echo "Resource Group Name: ${resourceGroupName}" - -location="$2" -echo "Location: ${location}" - -identityName="$3" -echo "Identity Name: ${identityName}" - -# Informing the user about the identity creation step -echo "Creating identity '${identityName}' in resource group '${resourceGroupName}' located in '${location}'..." - -# Executing the Azure CLI command to create an identity and storing the output in a variable. -output=$(az identity create \ - --resource-group "${resourceGroupName}" \ - --name "${identityName}" \ - --location "${location}" 2>&1) - -# Checking the exit status of the last command executed and echoing appropriate messages. -if [ "$?" -eq 0 ]; then - echo "Identity '${identityName}' successfully created." -else - echo "Error occurred while creating identity '${identityName}': ${output}" - exit 1 -fi diff --git a/Deploy/Bash/Identity/createUserAssignedManagedIdentity.sh b/Deploy/Bash/Identity/createUserAssignedManagedIdentity.sh deleted file mode 100644 index a0cb783..0000000 --- a/Deploy/Bash/Identity/createUserAssignedManagedIdentity.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash - -# Parameters -identityResourceGroupName="$1" # Resource group of the managed identity -subscriptionId="$2" # Azure Subscription ID -identityName="$3" # Name of the Managed Identity -customRoleName="$4" # Custom Role Name - -# Constants -outputFile="./downloadedTempTemplates/identity/aibroleImageCreation-template.json" -windows365identityName="0af06dc6-e4b5-4f28-818e-e78e62d137a5" -globalAdminIdentityName= -branch="main" - -# Derive Current User Details -currentUserName=$(az account show --query user.name -o tsv) # Azure Logged in Username -currentAzureLoggedUser=$(az ad user show --id $currentUserName --query id -o tsv) # Azure Logged in User ID -identityId=$(az identity show --name $identityName --resource-group $identityResourceGroupName --query principalId -o tsv) # Managed Identity ID - -# Function to create custom role using a template -function createCustomRole() { - local subscriptionId=$1 - local group=$2 - local outputFile=$3 - local customRoleName=$4 - - local templateUrl="https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/$branch/Deploy/ARMTemplates/identity/aibRoleImageCreation-template.json" - - echo "Starting custom role creation..." - echo "Downloading image template from ${templateUrl}..." - - if ! wget --header="Cache-Control: no-cache" --header="Pragma: no-cache" "${templateUrl}" -O "${outputFile}"; then - echo "Error: Failed to download the image template." - exit 3 - fi - - echo "Successfully downloaded the image template to ${outputFile}." - echo "Custom Role Name is ${customRoleName}" - - echo "Updating placeholders in the template..." - sed -i "s//${subscriptionId}/g" "${outputFile}" - sed -i "s//${group}/g" "${outputFile}" - sed -i "s//${customRoleName}/g" "${outputFile}" - - if [ $? -ne 0 ]; then - echo "Error: Failed to update placeholders in the template." - exit 4 - fi - - echo "Template placeholders updated." - az role definition create --role-definition "${outputFile}" - echo "Custom role creation completed." -} - -# Function to assign a role to an identity -function assignRole() { - local identityId=$1 - local roleName=$2 - local subscriptionId=$3 - - echo "Starting role assignment..." - echo "Assigning '$roleName' role to the identity $identityId for subscriptionId ${subscriptionId}" - - if az role assignment create --assignee "${identityId}" --role "${roleName}" --scope /subscriptions/"${subscriptionId}"; then - echo "'$roleName' role successfully assigned to the identity in the subscriptionId." - else - echo "Error: Failed to assign '$roleName' role to the identity." - exit 2 - fi - echo "Role assignment completed." -} - -# Main Script Execution -echo "Script started." - -createCustomRole "$subscriptionId" "$identityResourceGroupName" "$outputFile" "$customRoleName" - -assignRole "$identityId" "Virtual Machine Contributor" "$subscriptionId" -assignRole "$identityId" "Desktop Virtualization Contributor" "$subscriptionId" -assignRole "$identityId" "Desktop Virtualization Virtual Machine Contributor" "$subscriptionId" -assignRole "$identityId" "Desktop Virtualization Workspace Contributor" "$subscriptionId" -assignRole "$identityId" "Compute Gallery Sharing Admin" "$subscriptionId" -assignRole "$identityId" "Virtual Machine Contributor" "$subscriptionId" -assignRole "$identityId" "Virtual Machine Local User Login" "$subscriptionId" -assignRole "$identityId" "Managed Identity Operator" "$subscriptionId" -assignRole "$identityId" "$customRoleName" "$subscriptionId" -assignRole "$windows365identityName" "Reader" "$subscriptionId" -assignRole "$currentAzureLoggedUser" "DevCenter Dev Box User" "$subscriptionId" - -echo "Script completed." diff --git a/Deploy/Bash/Identity/login.sh b/Deploy/Bash/Identity/login.sh deleted file mode 100644 index cbfbd13..0000000 --- a/Deploy/Bash/Identity/login.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# Ensure the script stops on the first error -set -e - -# Ensure a command line argument is provided -if [ "$#" -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Assigning argument to a variable for better readability -subscriptionId=$1 - -# Step 1: Logging in to Azure -echo "Attempting to log in to Azure..." -az login -echo "Successfully logged in to Azure." - -# Step 2: Setting the Azure subscription -echo "Attempting to set subscription to ${subscriptionId}..." -# Check if the subscription exists and is valid -if az account set --subscription "${subscriptionId}"; then - echo "Successfully set Azure subscription to ${subscriptionId}." -else - echo "Failed to set Azure subscription to ${subscriptionId}. Please check if the subscription ID is valid and you have access to it." - exit 1 -fi - -# Additional comments for future steps or improvements can be added below this line. diff --git a/Deploy/Bash/Identity/registerFeatures.sh b/Deploy/Bash/Identity/registerFeatures.sh deleted file mode 100644 index 212e559..0000000 --- a/Deploy/Bash/Identity/registerFeatures.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -set -e -set -o nounset -set -o pipefail - -# Function to check the installation of Azure CLI -function checkAzCli() { - if ! command -v az &> /dev/null; then - echo "Error: 'az' command is not found. Please ensure Azure CLI is installed." - exit 1 - else - echo "'az' command is available. Continuing with the script..." - fi -} - -# Function to register an Azure provider and display a corresponding message. -function registerProvider() { - local providerName="$1" - local description="$2" - - echo "Starting registration for $description..." - - if az provider register -n "$providerName"; then - echo "Successfully registered $description." - else - echo "Failed to register $description." - exit 1 - fi -} - -echo "Beginning Azure Resource Providers registration..." - -# Check Azure CLI installation -checkAzCli - -# Define an array with providers and their descriptions -providers=( - "Microsoft.VirtualMachineImages|Azure Resource Provider for Virtual Machine Images" - "Microsoft.Compute|Azure Resource Provider for Compute" - "Microsoft.KeyVault|Azure Resource Provider for Key Vault" - "Microsoft.Storage|Azure Resource Provider for Storage" - "Microsoft.Network|Azure Resource Provider for Network" - "Microsoft.DevCenter|Azure Resource Provider for Dev Center" -) - -# Loop through each provider and initiate the registration process -for provider in "${providers[@]}"; do - IFS='|' read -ra parts <<< "$provider" - registerProvider "${parts[0]}" "${parts[1]}" -done - -az extension add --name devcenter - -echo "Azure Resource Providers registration process completed." diff --git a/Deploy/Bash/deploy.sh b/Deploy/Bash/deploy.sh deleted file mode 100644 index 893c73f..0000000 --- a/Deploy/Bash/deploy.sh +++ /dev/null @@ -1,275 +0,0 @@ -#!/bin/bash - -clear - -# Functions - -function login() { - # Declaring 'local' makes 'subscriptionName' a local variable, restricting its scope to within this function. - local subscriptionName="$1" # $1 represents the first argument passed to the function. - - # Check if the subscriptionName is empty and print a helpful message if it is. - if [[ -z "$subscriptionName" ]]; then - echo "Error: Subscription name is missing!" - echo "Usage: login " - return 1 - fi - - echo "Attempting to login to Azure subscription: $subscriptionName" - - # The path to 'login.sh' script. This script presumably handles Azure CLI login details. - local scriptPath='./identity/login.sh' - - # Check if the login.sh script exists and is executable, if not print a helpful message. - if [[ ! -x "$scriptPath" ]]; then - echo "Error: The login script $scriptPath does not exist or is not executable." - return 1 - fi - - # Execute the login script with the provided subscription name. - "$scriptPath" "$subscriptionName" - - # Check the exit status of the last command (login.sh) and print appropriate message. - if [[ $? -eq 0 ]]; then - echo "Successfully logged in to $subscriptionName." - else - echo "Failed to log in to $subscriptionName." - return 1 - fi -} - -function createResourceGroup { - local resourceGroupName=$1 - local location=$2 - - # Exit on error - set -e - - # Validate inputs - if [ -z "$resourceGroupName" ] || [ -z "$location" ]; then - echo "Usage: $0 " - exit 1 - fi - - # Echo steps - echo "Creating Azure Resource Group..." - echo "Resource Group Name: $resourceGroupName" - echo "Location: $location" - - # Creating Azure Resource Group - az group create \ - --name "$resourceGroupName" \ - --location "$location" \ - --tags "division=Contoso-Platform" \ - "Environment=Prod" \ - "offer=Contoso-DevWorkstation-Service" \ - "Team=Engineering" \ - "division=Contoso-Platform" \ - "solution=eShop" - - # Echo successful creation - echo "Resource group '$resourceGroupName' created successfully." -} - -function createIdentity { - local identityName=$1 - local resourceGroupName=$2 - local subscriptionId=$3 - local customRoleName=$4 - local location=$5 - - # Validate the presence of all parameters - if [[ -z $identityName || -z $resourceGroupName || -z $subscriptionId || -z $customRoleName || -z $location ]]; then - echo "Error: Missing required parameters." - echo "Usage: createIdentity " - return 1 - fi - - ./identity/createIdentity.sh "$resourceGroupName" "$location" "$identityName" - ./identity/registerFeatures.sh - ./identity/createUserAssignedManagedIdentity.sh "$resourceGroupName" "$subscriptionId" "$identityName" "$customRoleName" - -} - -function deploynetwork() { - # Local variables to store function arguments - local vnetName="$1" - local subNetName="$2" - local networkConnectionName="$3" - local resourceGroupName="$4" - local subscriptionId="$5" - local location="$6" - - # Check if the deployVnet.sh script exists before attempting to execute it - if [ ! -f "./network/deployVnet.sh" ]; then - echo "Error: deployVnet.sh script not found." - return 1 - fi - - # Execute the deployVnet.sh script with the passed parameters and capture its exit code - ./network/deployVnet.sh "$resourceGroupName" "$location" "$vnetName" "$subNetName" - ./network/createNetWorkConnection.sh "$location" "$resourceGroupName" "$vnetName" "$subNetName" "$networkConnectionName" - local exitCode="$?" - - # Check the exit code of the deployVnet.sh script and echo appropriate message - if [ "$exitCode" -ne 0 ]; then - echo "Error: Deployment of Vnet failed with exit code $exitCode." - return 1 - fi -} - -# This function deploys a Compute Gallery to a specified location and resource group. -# It receives three parameters: -# 1. imageGalleryName: The name of the Compute Gallery -# 2. location: The Azure region where the Compute Gallery will be deployed -# 3. galleryResourceGroupName: The name of the resource group where the Compute Gallery will be placed - -function deployComputeGallery { - local imageGalleryName="$1" # The name of the Compute Gallery to deploy - local location="$2" # The Azure location (region) where the Compute Gallery will be deployed - local galleryResourceGroupName="$3" # The resource group where the Compute Gallery will reside - - # The actual deployment command. Using a relative path to the deployment script - ./devBox/computeGallery/deployComputeGallery.sh "$imageGalleryName" "$location" "$galleryResourceGroupName" -} - -# Function to deploy Dev Center -function deployDevCenter() { - local devCenterName="$1" - local networkConnectionName="$2" - local imageGalleryName="$3" - local location="$4" - local identityName="$5" - local devBoxResourceGroupName="$6" - local networkResourceGroupName="$7" - local identityResourceGroupName="$8" - local imageGalleryResourceGroupName="$9" - - # Validate that all required parameters are provided - if [ -z "$devCenterName" ] || [ -z "$networkConnectionName" ] || [ -z "$imageGalleryName" ] || [ -z "$location" ] || [ -z "$identityName" ] || [ -z "$devBoxResourceGroupName" ] || [ -z "$networkResourceGroupName" ] || [ -z "$identityResourceGroupName" ] || [ -z "$imageGalleryResourceGroupName" ]; then - echo "Error: Missing required parameters." - return 1 # Return with error code - fi - - # Execute the deployDevCenter.sh script with the provided parameters and capture its exit code - ./devBox/devCenter/deployDevCenter.sh "$devCenterName" "$networkConnectionName" "$imageGalleryName" "$location" "$identityName" "$devBoxResourceGroupName" "$networkResourceGroupName" "$identityResourceGroupName" "$imageGalleryResourceGroupName" - -} - -function createDevCenterProject() { - local location="$1" - local subscriptionId="$2" - local resourceGroupName="$3" - local devCenterName="$4" - - # Check if the necessary parameters are provided - if [[ -z "$location" || -z "$subscriptionId" || -z "$resourceGroupName" || -z "$devCenterName" ]]; then - echo "Error: Missing required parameters." - echo "Usage: createDevCenterProject " - return 1 - fi - - # Validate if the createDevCenterProject.sh script exists before executing - if [[ ! -f "./devBox/devCenter/createDevCenterProject.sh" ]]; then - echo "Error: createDevCenterProject.sh script not found!" - return 1 - fi - - ./devBox/devCenter/createDevCenterProject.sh "$location" "$subscriptionId" "$resourceGroupName" "$devCenterName" -} - -function buildImage -{ - local subscriptionId="$1" - local imageGalleryResourceGroupName="$2" - local location="$3" - local identityName="$4" - local galleryName="$5" - local identityResourceGroupName="$6" - local devBoxResourceGroupName="$7" - local networkConnectionName="$8" - - declare -A image_params - #image_params["FrontEnd-Docker-Img"]="VSCode-FrontEnd-Docker Contoso-Fabric ./DownloadedTempTemplates/FrontEnd-Docker-Output.json https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/$branch/Deploy/ARMTemplates/computeGallery/frontEndEngineerImgTemplate.json Contoso" - image_params["BackEnd-Docker-Img"]="VS22-BackEnd-Docker Contoso-Fabric ./DownloadedTempTemplates/BackEnd-Docker-Output.json https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/$branch/Deploy/ARMTemplates/computeGallery/backEndEngineerImgTemplate.json Contoso" - - for imageName in "${!image_params[@]}"; do - IFS=' ' read -r imgSKU offer outputFile imageTemplateFile publisher <<< "${image_params[$imageName]}" - ./devBox/computeGallery/createVMImageTemplate.sh "$outputFile" "$subscriptionId" "$imageGalleryResourceGroupName" "$location" "$imageName" "$identityName" "$imageTemplateFile" "$galleryName" "$offer" "$imgSKU" "$publisher" "$identityResourceGroupName" - ./devBox/devCenter/createDevBoxDefinition.sh "$subscriptionId" "$location" "$devBoxResourceGroupName" "$devCenterName" "$galleryName" "$imageName" "$networkConnectionName" - done -} - - -set -e - -# Variables -branch="main" -location='WestUS3' - -# Validate if subscriptionName is provided -if [ -z "$1" ]; then - echo "Usage: $0 " - exit 1 -fi - -subscriptionName=$1 -subscriptionId=$(az account show --query id --output tsv) - -# Resource Group names -devBoxResourceGroupName='ContosoFabric-DevBox-RG' -imageGalleryResourceGroupName='ContosoFabric-ImageGallery-RG' -identityResourceGroupName='ContosoFabric-Identity-DevBox-RG' -networkResourceGroupName='eShop-Network-Connectivity-RG' -managementResourceGroupName='ContosoFabric-DevBox-Management-RG' - -# Identity Variables -identityName='ContosoFabricDevBoxImgBldId' -customRoleName='ContosoFabricBuilderRole' - -# Image and DevCenter Names -imageGalleryName='ContosoFabricImageGallery' -frontEndImageName='eShop-FrontEnd' -backEndImageName='eShop-BackEnd' -devCenterName='DevBox-DevCenter' - -# Network Variables -vnetName='eShop-Vnet' -subNetName='eShop-SubNet' -networkConnectionName='eShop-DevBox-Network-Connection' - -# Execute the script with proper sequence -echo "Starting Deployment..." - -# Login to Azure -login "$subscriptionName" - -# Deploy Resource Groups -createResourceGroup "$devBoxResourceGroupName" "$location" -createResourceGroup "$imageGalleryResourceGroupName" "$location" -createResourceGroup "$identityResourceGroupName" "$location" -createResourceGroup "$networkResourceGroupName" "$location" -createResourceGroup "$managementResourceGroupName" "$location" - -# ... Here you would call the other functions in a similar fashion - -echo "Deployment Completed Successfully!" - - -# Deploy Identity -createIdentity $identityName $identityResourceGroupName $subscriptionId $customRoleName $location - -# Deploy network -deploynetwork $vnetName $subNetName $networkConnectionName $networkResourceGroupName $subscriptionId $location - -# Deploy Compute Gallery -deployComputeGallery $imageGalleryName $location $imageGalleryResourceGroupName - -# Deploy Dev Center -deployDevCenter $devCenterName $networkConnectionName $imageGalleryName $location $identityName $devBoxResourceGroupName $networkResourceGroupName $identityResourceGroupName $imageGalleryResourceGroupName - -# Creating Dev Center Project -createDevCenterProject $location $subscriptionId $devBoxResourceGroupName $devCenterName - -# Building Images -buildImage $subscriptionId $imageGalleryResourceGroupName $location $identityName $imageGalleryName $identityResourceGroupName $devBoxResourceGroupName $networkConnectionName \ No newline at end of file diff --git a/Deploy/Bash/network/createNetWorkConnection.sh b/Deploy/Bash/network/createNetWorkConnection.sh deleted file mode 100644 index 77bba9b..0000000 --- a/Deploy/Bash/network/createNetWorkConnection.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -# Ensure all required parameters are provided -if [ "$#" -ne 5 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Assign positional parameters to meaningful variable names -location="$1" -networkResourceGroupName="$2" -vnetName="$3" -subNetName="$4" -networkConnectionName="$5" - -# Echo starting the operation -echo "Initiating the deployment in the resource group: $networkResourceGroupName, location: $location." - -# Retrieve the subnet ID -echo "Retrieving Subnet ID for $subNetName..." -subnetId=$(az network vnet subnet show \ - --resource-group "$networkResourceGroupName" \ - --vnet-name "$vnetName" \ - --name "$subNetName" \ - --query id \ - --output tsv) - -# Check the successful retrieval of subnetId -if [ -z "$subnetId" ]; then - echo "Error: Unable to retrieve the Subnet ID for $subNetName in $vnetName." - exit 1 -fi -echo "Subnet ID for $subNetName retrieved successfully." - - -echo "Deploying Network Connection" -az devcenter admin network-connection create \ - --location "$location" \ - --domain-join-type "AzureADJoin" \ - --subnet-id "$subnetId" \ - --name "$networkConnectionName" \ - --resource-group "$networkResourceGroupName" - -# Check the status of the last command - -if [ $? -eq 0 ]; then - echo "Deployment initiated successfully." -else - echo "Error: Deployment failed." - exit 1 -fi - -# Exit normally -exit 0 diff --git a/Deploy/Bash/network/deployVnet.sh b/Deploy/Bash/network/deployVnet.sh deleted file mode 100644 index d9aeb9f..0000000 --- a/Deploy/Bash/network/deployVnet.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -# This script creates an Azure Virtual Network and Subnet within a specified Resource Group. - -# Exit if any command fails -set -e - -# Check if az CLI is installed -if ! command -v az &> /dev/null -then - echo "az CLI could not be found. Please install it before running this script." - exit -fi - -# Ensure required arguments are passed -if [ "$#" -ne 4 ]; then - echo "Usage: $0 " - exit 1 -fi - -# Assign arguments to meaningful variable names with comments. -resourceGroupName="$1" # Name of the resource group. -location="$2" # Azure Region location where the resources will be created. -vnetName="$3" # Name of the virtual network. -subnetName="$4" # Name of the subnet to be created within the virtual network. - -# Declare additional variables with comments. -vnetAddressPrefix="10.0.0.0/16" # Address prefix for the virtual network. -subnetAddressPrefix="10.0.0.0/24" # Address prefix for the subnet within the virtual network. - -# Inform the user about the start of the process. -echo "Starting the creation of Virtual Network and Subnet..." - -# Create the Virtual Network and Subnet using the Azure CLI. -echo "Creating Virtual Network: $vnetName in Resource Group: $resourceGroupName with address prefix: $vnetAddressPrefix..." -az network vnet create \ - --resource-group "$resourceGroupName" \ - --location "$location" \ - --name "$vnetName" \ - --address-prefix "$vnetAddressPrefix" \ - --subnet-name "$subnetName" \ - --subnet-prefix "$subnetAddressPrefix" \ - --tags "division=Contoso-Platform" \ - "Environment=Prod" \ - "offer=Contoso-DevWorkstation-Service" \ - "Team=Engineering" \ - "division=Contoso-Platform" \ - "solution=eShop" - -# Inform the user that the resources have been created successfully. -echo "Virtual Network $vnetName and Subnet $subnetName have been created successfully in Resource Group $resourceGroupName with tags $tags." - diff --git a/Deploy/PowerShell/CleanUp.ps1 b/Deploy/PowerShell/CleanUp.ps1 deleted file mode 100644 index 11e2736..0000000 --- a/Deploy/PowerShell/CleanUp.ps1 +++ /dev/null @@ -1,95 +0,0 @@ -# Declaring Variables -.\Identity\login.ps1 Evilazaro-CSA-Self-Learning -# Resources Organization -$subscriptionId = (Get-AzureRmContext).Subscription.Id -$devBoxResourceGroupName = 'ContosoFabric-DevBox-RG' -$imageGalleryResourceGroupName = 'ContosoFabric-ImageGallery-RG' -$identityResourceGroupName = 'ContosoFabric-Identity-DevBox-RG' -$networkResourceGroupName = 'eShop-Network-Connectivity-RG' -$managementResourceGroupName = 'ContosoFabric-DevBox-Management-RG' -$networkWatcherResourceGroupName = 'NetworkWatcherRG' -$location = 'WestUS3' - -# Identity -$identityName = 'ContosoFabricDevBoxImgBldId' -$customRoleName = 'ContosoFabricBuilderRole' - -# Function to delete a resource group -function Delete-ResourceGroup { - param ( - [string]$resourceGroupName - ) - - if (Get-AzureRmResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue) { - Write-Host "Deleting resource group: $resourceGroupName..." - Remove-AzureRmResourceGroup -Name $resourceGroupName -Force -AsJob - Write-Host "Resource group $resourceGroupName deletion initiated." - } else { - Write-Host "Resource group $resourceGroupName does not exist. Skipping deletion." - } -} - -# Function to remove a role -function Remove-Role { - param ( - [string]$customRoleName - ) - - $output = Get-AzureRmRoleDefinition -Name $customRoleName -ErrorAction SilentlyContinue - - if ($null -eq $output) { - Write-Host "'$customRoleName' role does not exist. Skipping deletion." - } else { - Write-Host "Deleting the '$customRoleName' role..." - Remove-AzureRmRoleDefinition -Name $customRoleName -Force - Write-Host "'$customRoleName' role successfully deleted." - } -} - - -# Function to remove a role assignment -function Remove-RoleAssignment { - param ( - [string]$roleId, - [string]$subscriptionId - ) - - Write-Host "Checking the role assignments for the identity..." - - if ([string]::IsNullOrEmpty($roleId)) { - Write-Host "Role not defined. Skipping role assignment deletion." - return - } - - $output = Get-AzureRmRoleAssignment -RoleDefinitionId $roleId -Scope "/subscriptions/$subscriptionId" -ErrorAction SilentlyContinue - - if ($null -eq $output) { - Write-Host "'$roleId' role assignment does not exist. Skipping deletion." - } else { - Write-Host "Removing '$roleId' role assignment from the identity..." - Remove-AzRoleAssignment -RoleDefinitionId $roleId -Scope "/subscriptions/$subscriptionId" -Force - Write-Host "'$roleId' role assignment successfully removed." - } -} - -# Deleting role assignments and role definitions -$roleNames = @('Owner', 'Managed Identity Operator', 'Reader', 'DevCenter Dev Box User', $customRoleName) - -foreach ($roleName in $roleNames) { - Write-Host "Getting the role ID for '$roleName'..." - $roleId = (Get-AzureRmRoleDefinition -Name $roleName).Id - - Remove-RoleAssignment -roleId $roleId -subscriptionId $subscriptionId -} - -Remove-Role -customRoleName $customRoleName - -# Deleting resource groups -Delete-ResourceGroup -resourceGroupName $devBoxResourceGroupName -Delete-ResourceGroup -resourceGroupName $imageGalleryResourceGroupName -Delete-ResourceGroup -resourceGroupName $identityResourceGroupName -Delete-ResourceGroup -resourceGroupName $networkResourceGroupName -Delete-ResourceGroup -resourceGroupName $managementResourceGroupName -Delete-ResourceGroup -resourceGroupName $networkWatcherResourceGroupName -Delete-ResourceGroup -resourceGroupName "Default-ActivityLogAlerts" -Delete-ResourceGroup -resourceGroupName "DefaultResourceGroup-WUS2" diff --git a/Deploy/PowerShell/DevBox/computeGallery/buildVMImage.ps1 b/Deploy/PowerShell/DevBox/computeGallery/buildVMImage.ps1 deleted file mode 100644 index cd3006e..0000000 --- a/Deploy/PowerShell/DevBox/computeGallery/buildVMImage.ps1 +++ /dev/null @@ -1,81 +0,0 @@ -# Ensure that the necessary number of arguments are provided -if ($args.Length -ne 11) { - Write-Host "Usage: $ScriptName outputFile subscriptionID resourceGroupName location imageName identityName imageTemplateFile galleryName offer imgSKU publisher" - exit 1 -} - -# Assign command-line arguments to variables -$outputFile = $args[0] -$subscriptionID = $args[1] -$resourceGroupName = $args[2] -$location = $args[3] -$imageName = $args[4] -$identityName = $args[5] -$imageTemplateFile = $args[6] -$galleryName = $args[7] -$offer = $args[8] -$imgSKU = $args[9] -$publisher = $args[10] - -# Starting the process to create image definitions -Write-Host "Initiating the process to create image definitions..." - -# Construct image definition name and feature list -$imageDefName = "${imageName}-def" -$features = "SecurityType=TrustedLaunch IsHibernateSupported=true" - -# Creating image definition using az cli -Write-Host "Creating image definition..." -az sig image-definition create ` - --resource-group $resourceGroupName ` - --gallery-name $galleryName ` - --gallery-image-definition $imageDefName ` - --os-type Windows ` - --publisher $publisher ` - --offer $offer ` - --sku $imgSKU ` - --os-state generalized ` - --hyper-v-generation V2 ` - --features "$features" ` - --location $location ` - --tags "division=Contoso-Platform" ` - "Environment=Prod" ` - "offer=Contoso-DevWorkstation-Service" ` - "Team=Engineering" ` - "division=Contoso-Platform" ` - "solution=eShop" ` - "businessUnit=e-Commerce" - -# Download the image template file -Write-Host "Downloading image template from $imageTemplateFile..." -Invoke-WebRequest -Uri $imageTemplateFile -OutFile $outputFile -Write-Host "Image template successfully downloaded to $outputFile." - -# Replacing placeholders in the downloaded template with actual values -Write-Host "Updating placeholders in the template..." -(Get-Content $outputFile) | ForEach-Object {$_ -replace '', $subscriptionID} | Set-Content $outputFile -(Get-Content $outputFile) | ForEach-Object {$_ -replace '', $resourceGroupName} | Set-Content $outputFile -(Get-Content $outputFile) | ForEach-Object {$_ -replace '', $imageName} | Set-Content $outputFile -(Get-Content $outputFile) | ForEach-Object {$_ -replace '', $imageDefName} | Set-Content $outputFile -(Get-Content $outputFile) | ForEach-Object {$_ -replace '', $galleryName} | Set-Content $outputFile -(Get-Content $outputFile) | ForEach-Object {$_ -replace '', $location} | Set-Content $outputFile -(Get-Content $outputFile) | ForEach-Object {$_ -replace '', $identityName} | Set-Content $outputFile -Write-Host "Template placeholders successfully updated." - -# Deploy resources in Azure using the updated template -Write-Host "Creating image resource '$imageName' in Azure..." -az deployment group create ` - --resource-group $resourceGroupName ` - --template-file $outputFile - -Write-Host "Image resource '$imageName' successfully created in Azure." - -# Initiate the build process for the image in Azure -Write-Host "Initiating the build process for image '$imageName' in Azure..." -az resource invoke-action ` - --ids (az resource show --name $imageName --resource-group $resourceGroupName --resource-type "Microsoft.VirtualMachineImages/imageTemplates" --query id --output tsv) ` - --action "Run" ` - --request-body '{}' ` - --query properties.outputs - -Write-Host "Build process for image '$imageName' successfully initiated in Azure." diff --git a/Deploy/PowerShell/DevBox/computeGallery/createVMImageTemplate.ps1 b/Deploy/PowerShell/DevBox/computeGallery/createVMImageTemplate.ps1 deleted file mode 100644 index 608c721..0000000 --- a/Deploy/PowerShell/DevBox/computeGallery/createVMImageTemplate.ps1 +++ /dev/null @@ -1,88 +0,0 @@ -# This script creates an image definition in a shared image gallery, retrieves the IDs of image gallery and user-assigned identity, -# creates a deployment group and invokes an action on a resource. - -# Ensure the script exits when a command fails -$ErrorActionPreference = "Stop" - -# Usage instructions for the script if not all parameters are provided -if ($args.Length -lt 12) { - Write-Host "Usage: .ps1 " - exit 1 -} - -# Assign command-line arguments to variables with descriptive names -$outputFile = $args[0] -$subscriptionID = $args[1] -$resourceGroupName = $args[2] -$location = $args[3] -$imageName = $args[4] -$identityName = $args[5] -$imageFileUri = $args[6] -$galleryName = $args[7] -$offer = $args[8] -$imgSKU = $args[9] -$publisher = $args[10] -$identityResourceGroupName = $args[11] - -# Construct image definition name -$imageDefName = "${imageName}Def" - -# Define image features -$features = "SecurityType=TrustedLaunch IsHibernateSupported=true" - -# Log the step being executed -Write-Host "Creating image definition..." - -# Create image definition in a shared image gallery -az sig image-definition create ` - --resource-group "$resourceGroupName" ` - --gallery-name "$galleryName" ` - --gallery-image-definition "$imageDefName" ` - --os-type Windows ` - --publisher "$publisher" ` - --offer "$offer" ` - --sku "$imgSKU" ` - --os-state generalized ` - --hyper-v-generation V2 ` - --features "$features" ` - --location "$location" ` - --tags "division=Contoso-Platform" "Environment=Prod" "offer=Contoso-DevWorkstation-Service" "Team=Engineering" "solution=eShop" "businessUnit=e-Commerce" - -# Log the step being executed -Write-Host "Retrieving the ID of the image gallery..." - -# Retrieve the ID of the image gallery -$imageGalleryId = az sig show --resource-group "$resourceGroupName" ` - --gallery-name "$galleryName" --query id --output tsv - -# Log the step being executed -Write-Host "Retrieving the ID of the user-assigned identity..." - -# Retrieve the ID of the user-assigned identity -$userAssignedId = az identity show --resource-group "$identityResourceGroupName" ` - --name "$identityName" --query id --output tsv - -# Log the step being executed -Write-Host "Creating a deployment group..." - -# Create a deployment group -az deployment group create ` - --resource-group "$resourceGroupName" ` - --template-uri "$imageFileUri" ` - --parameters imgName="$imageName" ` - imageGalleryId="$imageGalleryId" ` - userAssignedId="$userAssignedId" ` - location="$location" - -# Log the step being executed -Write-Host "Invoking an action on the resource..." - -# Invoke an action on the resource -az resource invoke-action ` - --ids $(az resource show --name "$imageName" --resource-group "$resourceGroupName" --resource-type "Microsoft.VirtualMachineImages/imageTemplates" --query id --output tsv) ` - --action "Run" ` - --request-body '{}' ` - --query properties.outputs - -# Log the successful execution of the script -Write-Host "Script executed successfully." diff --git a/Deploy/PowerShell/DevBox/computeGallery/deployComputeGallery.ps1 b/Deploy/PowerShell/DevBox/computeGallery/deployComputeGallery.ps1 deleted file mode 100644 index a404f6f..0000000 --- a/Deploy/PowerShell/DevBox/computeGallery/deployComputeGallery.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -# Check if the correct number of arguments are passed, if not, exit with an error message -if ($args.Length -ne 3) { - Write-Host "Usage: .\.ps1 " - exit 1 -} - -# Assigning input arguments to descriptive variable names for better clarity and readability -$computeGalleryName = $args[0] -$location = $args[1] -$galleryResourceGroupName = $args[2] - -# Informing the user about the start of resource creation -Write-Host "Initializing the creation of a Shared Image Gallery named '$computeGalleryName' in resource group '$galleryResourceGroupName' located in '$location'." - -# Execute the Azure command to create the resource, with tags for better resource categorization and management -# Echoing the command before running it for better user awareness -Write-Host "Executing Azure CLI command to create the Shared Image Gallery..." -az sig create ` - --gallery-name $computeGalleryName ` - --resource-group $galleryResourceGroupName ` - --location $location ` - --tags "Division=Contoso-Platform" ` - "Environment=Prod" ` - "Offer=Contoso-DevWorkstation-Service" ` - "Team=Engineering" ` - "Solution=eShop" ` - "BusinessUnit=e-Commerce" - -# Confirming the successful creation of the resource -Write-Host "Shared Image Gallery '$computeGalleryName' successfully created in resource group '$galleryResourceGroupName' located in '$location'." diff --git a/Deploy/PowerShell/DevBox/devCenter/createDevBoxDefinition.ps1 b/Deploy/PowerShell/DevBox/devCenter/createDevBoxDefinition.ps1 deleted file mode 100644 index 46cb6b0..0000000 --- a/Deploy/PowerShell/DevBox/devCenter/createDevBoxDefinition.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -# Best Practices Revised PowerShell Script - -# Assigning input arguments to variables with more descriptive, camelCase names -param ( - [string]$subscriptionId, # subscription ID - [string]$location, # location - [string]$devBoxResourceGroupName, # resource group name - [string]$devCenterName, # development center name - [string]$galleryName, # gallery name - [string]$imageName, # image name - [string]$networkConnectionName # network connection name -) - -# Inform the user about the initialization step -Write-Host "Initializing script with subscriptionId: $subscriptionId, location: $location, devBoxResourceGroupName: $devBoxResourceGroupName, devCenterName: $devCenterName, galleryName: $galleryName, and imageName: $imageName." - -# Construct necessary variables with camelCase naming conventions -$imageReferenceId = "/subscriptions/$subscriptionId/resourceGroups/$devBoxResourceGroupName/providers/Microsoft.DevCenter/devcenters/$devCenterName/galleries/${galleryName}/images/${imageName}def/" -$devBoxDefinitionName = "devBox-$imageName" -$projectName = "eShop" -$poolName = "$imageName-pool" -$devBoxName = "$imageName-devbox" - -# Echo the constructed variables -Write-Host "Constructed variables: -imageReferenceId: $imageReferenceId -devBoxDefinitionName: $devBoxDefinitionName -networkConnectionName: $networkConnectionName -projectName: $projectName -poolName: $poolName -devBoxName: $devBoxName" - -# Creating a DevBox definition with camelCase variable names and added echo for step tracking -Write-Host "Creating DevBox definition..." -az devcenter admin devbox-definition create --location $location ` - --image-reference id=$imageReferenceId ` - --os-storage-type "ssd_256gb" ` - --sku name="general_i_8c32gb256ssd_v2" ` - --name $devBoxDefinitionName ` - --dev-center-name $devCenterName ` - --resource-group $devBoxResourceGroupName - -Write-Host "DevBox definition created successfully." - -# Creating DevBox Pools with added echo for step tracking -Write-Host "Creating DevBox Pools..." -.\devBox\devCenter\createDevBoxPools.ps1 $location $devBoxDefinitionName $networkConnectionName $poolName $projectName $devBoxResourceGroupName -Write-Host "DevBox Pools created successfully." - -# Creating DevBox for Engineers with added echo for step tracking -Write-Host "Creating DevBox for Engineers..." -.\devBox\devCenter\createDevBoxforEngineers.ps1 $poolName $devBoxName $devCenterName $projectName -Write-Host "DevBox for Engineers created successfully." diff --git a/Deploy/PowerShell/DevBox/devCenter/createDevBoxPools.ps1 b/Deploy/PowerShell/DevBox/devCenter/createDevBoxPools.ps1 deleted file mode 100644 index 2eeb485..0000000 --- a/Deploy/PowerShell/DevBox/devCenter/createDevBoxPools.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -# Define the usage of the script to inform users about expected parameters -function Usage { - Write-Output "Usage: $PSCommandPath " -} - -# Validate the number of arguments passed to the script -if ($args.Count -ne 6) { - Write-Output "Error: Incorrect number of arguments" - Usage - exit 1 -} - -# Assign arguments to variables with meaningful names in PascalCase -$Location = $args[0] -$DevBoxDefinitionName = $args[1] -$NetworkConnectionName = $args[2] -$PoolName = $args[3] -$ProjectName = $args[4] -$DevBoxResourceGroupName = $args[5] - -# Function to create a DevCenter admin pool -function CreateDevCenterAdminPool { - Write-Output "Creating DevCenter admin pool with the following parameters:" - Write-Output "Location: $Location" - Write-Output "DevBox Definition Name: $DevBoxDefinitionName" - Write-Output "Network Connection Name: $NetworkConnectionName" - Write-Output "Pool Name: $PoolName" - Write-Output "Project Name: $ProjectName" - Write-Output "Resource Group: $DevBoxResourceGroupName" - - az devcenter admin pool create ` - --location $Location ` - --devbox-definition-name $DevBoxDefinitionName ` - --network-connection-name $NetworkConnectionName ` - --pool-name $PoolName ` - --project-name $ProjectName ` - --resource-group $DevBoxResourceGroupName ` - --local-administrator "Enabled" ` - --tags "Division=Contoso-Platform" ` - "Environment=Prod" ` - "Offer=Contoso-DevWorkstation-Service" ` - "Team=Engineering" ` - "Solution=eShop" - - # Check the exit status of the last command and echo a message accordingly - if ($LASTEXITCODE -eq 0) { - Write-Output "DevCenter admin pool created successfully." - } else { - Write-Output "Failed to create DevCenter admin pool. Please check the parameters and try again." - exit 1 - } -} - -# Call the function to create a DevCenter admin pool -CreateDevCenterAdminPool diff --git a/Deploy/PowerShell/DevBox/devCenter/createDevBoxforEngineers.ps1 b/Deploy/PowerShell/DevBox/devCenter/createDevBoxforEngineers.ps1 deleted file mode 100644 index 63e4547..0000000 --- a/Deploy/PowerShell/DevBox/devCenter/createDevBoxforEngineers.ps1 +++ /dev/null @@ -1,56 +0,0 @@ -# Check if the correct number of arguments has been provided -if ($args.Length -ne 4) { - Write-Host "Usage: " - exit 1 -} - -# Assign command line arguments to variables with meaningful names -$poolName = $args[0] -$devBoxName = $args[1] -$devCenterName = $args[2] -$projectName = $args[3] - -# Inform the user about the values received -Write-Host "Creating Dev Box with:" -Write-Host "Pool Name: $poolName" -Write-Host "Dev Box Name: $devBoxName" -Write-Host "Dev Center Name: $devCenterName" -Write-Host "Project Name: $projectName" - -# Obtain the current Azure logged user name and ID -Write-Host "Retrieving current Azure logged user information..." -$currentUserName = az account show --query user.name -o tsv - -if (-not $currentUserName) { - Write-Host "Error: Couldn't retrieve the current Azure user name. Exiting." - exit 1 -} - -Write-Host "Current Azure User Name: $currentUserName" - -$currentAzureLoggedUserID = az ad user show --id $currentUserName --query id -o tsv - -if (-not $currentAzureLoggedUserID) { - Write-Host "Error: Couldn't retrieve the current Azure user ID. Exiting." - exit 1 -} - -Write-Host "Current Azure User ID: $currentAzureLoggedUserID" - -# Create a dev box with specified parameters -Write-Host "Creating Dev Box..." -az devcenter dev dev-box create ` - --pool-name $poolName ` - --name $devBoxName ` - --dev-center-name $devCenterName ` - --project-name $projectName ` - --user-id $currentAzureLoggedUserID ` - --no-wait - -# Check if the dev box creation was successful -if ($LASTEXITCODE -eq 0) { - Write-Host "Dev Box '$devBoxName' has been created successfully!" -} else { - Write-Host "Error: Dev Box creation failed." - exit 1 -} diff --git a/Deploy/PowerShell/DevBox/devCenter/createDevCenterProject.ps1 b/Deploy/PowerShell/DevBox/devCenter/createDevCenterProject.ps1 deleted file mode 100644 index 1a6a7d6..0000000 --- a/Deploy/PowerShell/DevBox/devCenter/createDevCenterProject.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -# Define parameters -param ( - [string]$location, - [string]$subscriptionId, - [string]$devBoxResourceGroupName, - [string]$devCenterName -) - -# Define other variables -$description = "Sample .NET Core reference application, powered by Microsoft" -$projectName = "eShop" -$maxDevBoxesPerUser = "10" - -# Check for mandatory parameters and print usage information if they are not provided -if (-not $location -or -not $subscriptionId -or -not $devBoxResourceGroupName -or -not $devCenterName) { - Write-Host "Usage: .\script_name.ps1 " - exit 1 -} - -# Construct the dev-center-id -$devCenterId = "/subscriptions/$subscriptionId/resourceGroups/$devBoxResourceGroupName/providers/Microsoft.DevCenter/devcenters/$devCenterName" - -# Inform the user about the action to be performed -Write-Host "Creating a new devcenter admin project in Azure..." -Write-Host "Location: $location" -Write-Host "Subscription ID: $subscriptionId" -Write-Host "Resource Group Name: $devBoxResourceGroupName" -Write-Host "Dev Center Name: $devCenterName" -Write-Host "Description: $description" -Write-Host "Project Name: $projectName" -Write-Host "Max Dev Boxes Per User: $maxDevBoxesPerUser" - -# Run the Azure CLI command to create a devcenter admin project -az devcenter admin project create ` - --location "$location" ` - --description "$description" ` - --dev-center-id "$devCenterId" ` - --name "$projectName" ` - --resource-group "$devBoxResourceGroupName" ` - --max-dev-boxes-per-user "$maxDevBoxesPerUser" ` - --tags "division=Contoso-Platform" ` - "Environment=Prod" ` - "offer=Contoso-DevWorkstation-Service" ` - "Team=Engineering" ` - "solution=eShop" ` - "businessUnit=e-Commerce" - -# Check the status of the last command run and inform the user -if ($LASTEXITCODE -eq 0) { - Write-Host "Devcenter admin project '$projectName' has been created successfully!" -} else { - Write-Host "Failed to create devcenter admin project '$projectName'." -ForegroundColor Red - exit 2 -} diff --git a/Deploy/PowerShell/DevBox/devCenter/deployDevCenter.ps1 b/Deploy/PowerShell/DevBox/devCenter/deployDevCenter.ps1 deleted file mode 100644 index b38b054..0000000 --- a/Deploy/PowerShell/DevBox/devCenter/deployDevCenter.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# Exit script if any command fails -$ErrorActionPreference = "Stop" - -# Validate number of arguments -if ($args.Count -ne 9) { - Write-Output "Usage: " - exit 1 -} - -# Assign arguments to variables -$devCenterName = $args[0] -$networkConnectionName = $args[1] -$imageGalleryName = $args[2] -$location = $args[3] -$identityName = $args[4] -$devBoxResourceGroupName = $args[5] -$networkResourceGroupName = $args[6] -$identityResourceGroupName = $args[7] -$imageGalleryResourceGroupName = $args[8] - -Write-Output "Starting to deploy Dev Center with the following parameters:" -Write-Output "Dev Center Name: $devCenterName" -Write-Output "Network Connection Name: $networkConnectionName" -Write-Output "Image Gallery Name: $imageGalleryName" -Write-Output "Location: $location" -Write-Output "Identity Name: $identityName" -Write-Output "DevBox Resource Group Name: $devBoxResourceGroupName" -Write-Output "Network Resource Group Name: $networkResourceGroupName" -Write-Output "Identity Resource Group Name: $identityResourceGroupName" -Write-Output "Image Gallery Resource Group Name: $imageGalleryResourceGroupName" - -# Define other constants -$branch = "Dev" -$templateFileUri = "https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/$branch/Deploy/ARMTemplates/devBox/devCentertemplate.json" - -Write-Output "Fetching network connection id..." -$networkConnectionId = az devcenter admin network-connection list --resource-group $networkResourceGroupName --query "[0].id" --output tsv - -Write-Output "Fetching compute gallery id..." -$computeGalleryId = az sig show --resource-group $imageGalleryResourceGroupName --gallery-name $imageGalleryName --query id --output tsv - -Write-Output "Fetching user identity id..." -$userIdentityId = az identity show --resource-group $identityResourceGroupName --name $identityName --query id --output tsv - -Write-Output "Creating deployment group..." -az deployment group create ` - --name "$devCenterName" ` - --resource-group "$devBoxResourceGroupName" ` - --template-uri $templateFileUri ` - --parameters ` - devCenterName="$devCenterName" ` - networkConnectionId="$networkConnectionId" ` - computeGalleryId="$computeGalleryId" ` - location="$location" ` - networkConnectionName="$networkConnectionName" ` - userIdentityId="$userIdentityId" ` - computeGalleryImageName="$imageGalleryName" - -Write-Output "Deployment of Dev Center is complete." diff --git a/Deploy/PowerShell/DownloadedTempTemplates/.gitignore b/Deploy/PowerShell/DownloadedTempTemplates/.gitignore deleted file mode 100644 index 01192e4..0000000 --- a/Deploy/PowerShell/DownloadedTempTemplates/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# ignore all json files -*.json \ No newline at end of file diff --git a/Deploy/PowerShell/Identity/createIdentity.ps1 b/Deploy/PowerShell/Identity/createIdentity.ps1 deleted file mode 100644 index 98f62dc..0000000 --- a/Deploy/PowerShell/Identity/createIdentity.ps1 +++ /dev/null @@ -1,50 +0,0 @@ -<# -.SYNOPSIS -This script creates an identity on Microsoft Azure. - -.DESCRIPTION -It expects three parameters in the exact order: -1. ResourceGroupName - The name of the resource group. -2. Location - The location of the resource group. -3. IdentityName - The name of the identity to create. -#> - -param ( - [string]$ResourceGroupName, - [string]$Location, - [string]$IdentityName -) - -function Show-Usage { - Write-Output "Usage: $PSCommandPath -ResourceGroupName -Location -IdentityName " - Write-Output "Example: $PSCommandPath -ResourceGroupName myResourceGroup -Location EastUS -IdentityName myIdentity" - exit 1 -} - -# Check if the correct number of arguments is provided, if not, display usage information and exit. -if (-not $ResourceGroupName -or -not $Location -or -not $IdentityName) { - Write-Output "Error: Invalid number of arguments." - Show-Usage -} - -# Echoing the assignments. -Write-Output "Resource Group Name: $ResourceGroupName" -Write-Output "Location: $Location" -Write-Output "Identity Name: $IdentityName" - -# Informing the user about the identity creation step. -Write-Output "Creating identity '$IdentityName' in resource group '$ResourceGroupName' located in '$Location'..." - -# Executing the Azure CLI command to create an identity and storing the output in a variable. -$output = az identity create ` - --resource-group "$ResourceGroupName" ` - --name "$IdentityName" ` - --location "$Location" 2>&1 - -# Checking the exit status of the last command executed and echoing appropriate messages. -if ($LASTEXITCODE -eq 0) { - Write-Output "Identity '$IdentityName' successfully created." -} else { - Write-Output "Error occurred while creating identity '$IdentityName': $output" - exit 1 -} diff --git a/Deploy/PowerShell/Identity/createUserAssignedManagedIdentity.ps1 b/Deploy/PowerShell/Identity/createUserAssignedManagedIdentity.ps1 deleted file mode 100644 index df652a7..0000000 --- a/Deploy/PowerShell/Identity/createUserAssignedManagedIdentity.ps1 +++ /dev/null @@ -1,90 +0,0 @@ -# Parameters -param ( - [string]$identityResourceGroupName, # Resource group of the managed identity - [string]$subscriptionId, # Azure Subscription ID - [string]$identityName, # Name of the Managed Identity - [string]$customRoleName # Custom Role Name -) - -# Constants -$outputFile = ".\downloadedTempTemplates\identity\aibroleImageCreation-template.json" -$windows365identityName = "0af06dc6-e4b5-4f28-818e-e78e62d137a5" -$branch = "Dev" - -# Derive Current User Details -$currentUserName = az account show --query user.name -o tsv | Out-String | Trim # Azure Logged in Username -$currentAzureLoggedUser = az ad user show --id $currentUserName --query id -o tsv | Out-String | Trim # Azure Logged in User ID -$identityId = az identity show --name $identityName --resource-group $identityResourceGroupName --query principalId -o tsv | Out-String | Trim # Managed Identity ID - -function createCustomRole { - param ( - [string]$subscriptionId, - [string]$group, - [string]$outputFile, - [string]$customRoleName - ) - - $templateUrl = "https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/$branch/Deploy/ARMTemplates/identity/aibRoleImageCreation-template.json" - - Write-Host "Starting custom role creation..." - Write-Host "Downloading image template from ${templateUrl}..." - - try { - Invoke-WebRequest -Uri $templateUrl -Headers @{"Cache-Control"="no-cache"; "Pragma"="no-cache"} -OutFile $outputFile - } - catch { - Write-Host "Error: Failed to download the image template." - exit 3 - } - - Write-Host "Successfully downloaded the image template to ${outputFile}." - Write-Host "Custom Role Name is ${customRoleName}" - - Write-Host "Updating placeholders in the template..." - - (Get-Content $outputFile) -replace '', $subscriptionId -replace '', $group -replace '', $customRoleName | Set-Content $outputFile - - if ($LASTEXITCODE -ne 0) { - Write-Host "Error: Failed to update placeholders in the template." - exit 4 - } - - Write-Host "Template placeholders updated." - az role definition create --role-definition $outputFile | Out-Null - Write-Host "Custom role creation completed." -} - -function assignRole { - param ( - [string]$identityId, - [string]$roleName, - [string]$subscriptionId - ) - - Write-Host "Starting role assignment..." - Write-Host "Assigning '$roleName' role to the identity $identityId for subscriptionId ${subscriptionId}" - - try { - az role assignment create --assignee $identityId --role $roleName --scope /subscriptions/$subscriptionId | Out-Null - Write-Host "'$roleName' role successfully assigned to the identity in the subscriptionId." - } - catch { - Write-Host "Error: Failed to assign '$roleName' role to the identity." - exit 2 - } - - Write-Host "Role assignment completed." -} - -# Main Script Execution -Write-Host "Script started." - -createCustomRole $subscriptionId $identityResourceGroupName $outputFile $customRoleName - -assignRole $identityId "Owner" $subscriptionId -assignRole $identityId "Managed Identity Operator" $subscriptionId -assignRole $identityId $customRoleName $subscriptionId -assignRole $windows365identityName "Reader" $subscriptionId -assignRole $currentAzureLoggedUser "DevCenter Dev Box User" $subscriptionId - -Write-Host "Script completed." diff --git a/Deploy/PowerShell/Identity/login.ps1 b/Deploy/PowerShell/Identity/login.ps1 deleted file mode 100644 index 871f9f2..0000000 --- a/Deploy/PowerShell/Identity/login.ps1 +++ /dev/null @@ -1,29 +0,0 @@ -# Ensure a command line argument is provided -if ($args.Length -ne 1) { - Write-Host "Usage: $0 " - exit 1 -} - -# Assigning argument to a variable for better readability -$subscriptionName = $args[0] - -# Step 1: Logging in to Azure -Write-Host "Attempting to log in to Azure..." -Connect-AzureRmAccount -$subscriptionId = (Get-AzureRmSubscription -SubscriptionName $subscriptionName).Id -Write-Host "Successfully logged in to Azure." - -# Step 2: Setting the Azure subscription -Write-Host "Attempting to set subscription to $subscriptionId..." -try { - # Check if the subscription exists and is valid - az account set --subscription $subscriptionName - Set-AzureRmContext -Context (Get-AzureRmSubscription -SubscriptionId $subscriptionId) -ErrorAction Stop - Write-Host "Successfully set Azure subscription to $subscriptionId." -} catch { - Write-Host "Failed to set Azure subscription to $subscriptionId. Please check if the subscription ID is valid and you have access to it." - exit 1 -} - -# Additional comments for future steps or improvements can be added below this line. - diff --git a/Deploy/PowerShell/Identity/registerFeatures.ps1 b/Deploy/PowerShell/Identity/registerFeatures.ps1 deleted file mode 100644 index 8d4bd48..0000000 --- a/Deploy/PowerShell/Identity/registerFeatures.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -# Abort the script when a command fails -$ErrorActionPreference = "Stop" - -# Function to check the installation of Azure CLI -function Check-AzCli { - if (-not (Get-Command az -ErrorAction SilentlyContinue)) { - Write-Output "Error: 'az' command is not found. Please ensure Azure CLI is installed." - exit 1 - } else { - Write-Output "'az' command is available. Continuing with the script..." - } -} - -# Function to register an Azure provider and display a corresponding message. -function Register-Provider { - param ( - [string]$providerName, - [string]$description - ) - - Write-Output "Starting registration for $description..." - - try { - az provider register -n $providerName - Write-Output "Successfully registered $description." - } catch { - Write-Output "Failed to register $description." - exit 1 - } -} - -Write-Output "Beginning Azure Resource Providers registration..." - -# Check Azure CLI installation -Check-AzCli - -# Define a list with providers and their descriptions -$providers = @( - "Microsoft.VirtualMachineImages|Azure Resource Provider for Virtual Machine Images", - "Microsoft.Compute|Azure Resource Provider for Compute", - "Microsoft.KeyVault|Azure Resource Provider for Key Vault", - "Microsoft.Storage|Azure Resource Provider for Storage", - "Microsoft.Network|Azure Resource Provider for Network", - "Microsoft.DevCenter|Azure Resource Provider for Dev Center" -) - -# Loop through each provider and initiate the registration process -foreach ($provider in $providers) { - $parts = $provider -split '\|' - Register-Provider -providerName $parts[0] -description $parts[1] -} - -az extension add --name devcenter - -Write-Output "Azure Resource Providers registration process completed." diff --git a/Deploy/PowerShell/deploy.ps1 b/Deploy/PowerShell/deploy.ps1 deleted file mode 100644 index ea2b3ef..0000000 --- a/Deploy/PowerShell/deploy.ps1 +++ /dev/null @@ -1,112 +0,0 @@ -# Define the Functions - -Function Login { - Param ( - [string]$subscriptionName - ) - If(-not $subscriptionName){ - Write-Output "Error: Subscription name is missing!" - Write-Output "Usage: Login -subscriptionName " - Return - } - - Write-Output "Attempting to login to Azure subscription: $subscriptionName" - - $scriptPath = '.\identity\login.ps1' - - If(-not (Test-Path -Path $scriptPath -PathType Leaf)){ - Write-Output "Error: The login script $scriptPath does not exist or is not executable." - Return - } - - & $scriptPath $subscriptionName - - If($LASTEXITCODE -eq 0){ - Write-Output "Successfully logged in to $subscriptionName." - } - Else{ - Write-Output "Failed to log in to $subscriptionName." - Return - } -} - -Function CreateResourceGroup { - Param( - [string]$resourceGroupName, - [string]$location - ) - - # Validate inputs - If(-not $resourceGroupName -or -not $location){ - Write-Output "Usage: CreateResourceGroup -resourceGroupName -location " - Exit - } - - # Echo steps - Write-Output "Creating Azure Resource Group..." - Write-Output "Resource Group Name: $resourceGroupName" - Write-Output "Location: $location" - - az group create --name $resourceGroupName --location $location --tags division=Contoso-Platform Environment=Prod offer=Contoso-DevWorkstation-Service Team=Engineering division=Contoso-Platform solution=eShop - Write-Output "Resource group '$resourceGroupName' created successfully." -} - -# Define other functions similarly... -# ... - -# Set error action preference to Stop to exit on error -$ErrorActionPreference = 'Stop' - -# Variables -$branch = "Dev" -$location = 'WestUS3' - -# Validate if subscriptionName is provided -If(-not $args[0]){ - Write-Output "Usage: .\script.ps1 " - Exit -} - -$subscriptionName = $args[0] -$subscriptionId = az account show --query id --output tsv - -# Resource Group names -$devBoxResourceGroupName = 'ContosoFabric-DevBox-RG' -$imageGalleryResourceGroupName = 'ContosoFabric-ImageGallery-RG' -$identityResourceGroupName = 'ContosoFabric-Identity-DevBox-RG' -$networkResourceGroupName = 'eShop-Network-Connectivity-RG' -$managementResourceGroupName = 'ContosoFabric-DevBox-Management-RG' - -# Identity Variables -$identityName = 'ContosoFabricDevBoxImgBldId' -$customRoleName = 'ContosoFabricBuilderRole' - -# Image and DevCenter Names -$imageGalleryName = 'ContosoFabricImageGallery' -$frontEndImageName = 'eShop-FrontEnd' -$backEndImageName = 'eShop-BackEnd' -$devCenterName = 'DevBox-DevCenter' - -# Network Variables -$vnetName = 'eShop-Vnet' -$subNetName = 'eShop-SubNet' -$networkConnectionName = 'eShop-DevBox-Network-Connection' - -# Execute the script with proper sequence -Write-Output "Starting Deployment..." - -# Login to Azure -Login -subscriptionName $subscriptionName - -# Deploy Resource Groups -CreateResourceGroup -resourceGroupName $devBoxResourceGroupName -location $location -CreateResourceGroup -resourceGroupName $imageGalleryResourceGroupName -location $location -CreateResourceGroup -resourceGroupName $identityResourceGroupName -location $location -CreateResourceGroup -resourceGroupName $networkResourceGroupName -location $location -CreateResourceGroup -resourceGroupName $managementResourceGroupName -location $location - -# ... Here you would call the other functions in a similar fashion - -Write-Output "Deployment Completed Successfully!" - -# You will need to define and call the other functions similarly, adapting each part as needed according to the logic and flow of the original Bash script. diff --git a/Deploy/PowerShell/network/createNetWorkConnection.ps1 b/Deploy/PowerShell/network/createNetWorkConnection.ps1 deleted file mode 100644 index a77e8c8..0000000 --- a/Deploy/PowerShell/network/createNetWorkConnection.ps1 +++ /dev/null @@ -1,59 +0,0 @@ -# Define Variables -$branch = "Dev" - - -# Ensure all required parameters are provided -if ($args.Count -ne 5) { - Write-Host "Usage: $($MyInvocation.InvocationName) " - exit 1 -} - -# Assign positional parameters to meaningful variable names -$location = $args[0] -$networkResourceGroupName = $args[1] -$vnetName = $args[2] -$subNetName = $args[3] -$networkConnectionName = $args[4] - -# Define the template file path -$templateUrl = "https://raw.githubusercontent.com/Evilazaro/MicrosoftDevBox/$branch/Deploy/ARMTemplates/network/networkConnectionTemplate.json" - -# Echo starting the operation -Write-Host "Initiating the deployment in the resource group: $networkResourceGroupName, location: $location." - -# Retrieve the subnet ID -Write-Host "Retrieving Subnet ID for $subNetName..." -$subnetId = az network vnet subnet show ` - --resource-group $networkResourceGroupName ` - --vnet-name $vnetName ` - --name $subNetName ` - --query id ` - --output tsv - -# Check the successful retrieval of subnetId -if (-not $subnetId) { - Write-Host "Error: Unable to retrieve the Subnet ID for $subNetName in $vnetName." - exit 1 -} -Write-Host "Subnet ID for $subNetName retrieved successfully." - -# Deploy the ARM template -Write-Host "Deploying ARM Template from $templateUrl..." -az deployment group create ` - --resource-group $networkResourceGroupName ` - --template-uri $templateUrl ` - --parameters ` - name=$networkConnectionName ` - vnetId=$subnetId ` - location=$location - -# Check the status of the last command -if ($LASTEXITCODE -eq 0) { - Write-Host "ARM Template deployment initiated successfully." -} else { - Write-Host "Error: ARM Template deployment failed." - exit 1 -} - -# Exit normally -exit 0 diff --git a/Deploy/PowerShell/network/deployVnet.ps1 b/Deploy/PowerShell/network/deployVnet.ps1 deleted file mode 100644 index 19ffbb1..0000000 --- a/Deploy/PowerShell/network/deployVnet.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -# This script creates an Azure Virtual Network and Subnet within a specified Resource Group. - -# Exit if any command fails -$ErrorActionPreference = "Stop" - -# Check if az CLI is installed -if (-not (Get-Command "az" -ErrorAction SilentlyContinue)) { - Write-Host "az CLI could not be found. Please install it before running this script." - exit -} - -# Ensure required arguments are passed -if ($args.Length -ne 4) { - Write-Host "Usage: .\$($MyInvocation.MyCommand) " - exit 1 -} - -# Assign arguments to meaningful variable names with comments. -$resourceGroupName = $args[0] # Name of the resource group. -$location = $args[1] # Azure Region location where the resources will be created. -$vnetName = $args[2] # Name of the virtual network. -$subnetName = $args[3] # Name of the subnet to be created within the virtual network. - -# Declare additional variables with comments. -$vnetAddressPrefix = "10.0.0.0/16" # Address prefix for the virtual network. -$subnetAddressPrefix = "10.0.0.0/24" # Address prefix for the subnet within the virtual network. - -# Inform the user about the start of the process. -Write-Host "Starting the creation of Virtual Network and Subnet..." - -# Create the Virtual Network and Subnet using the Azure CLI. -Write-Host "Creating Virtual Network: $vnetName in Resource Group: $resourceGroupName with address prefix: $vnetAddressPrefix..." -az network vnet create ` - --resource-group $resourceGroupName ` - --location $location ` - --name $vnetName ` - --address-prefix $vnetAddressPrefix ` - --subnet-name $subnetName ` - --subnet-prefix $subnetAddressPrefix ` - --tags "division=Contoso-Platform" "Environment=Prod" "offer=Contoso-DevWorkstation-Service" "Team=Engineering" "division=Contoso-Platform" "solution=eShop" - -# Inform the user that the resources have been created successfully. -Write-Host "Virtual Network $vnetName and Subnet $subnetName have been created successfully in Resource Group $resourceGroupName." diff --git a/README.md b/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/CONTRIBUTING.MD b/docs/CONTRIBUTING.MD similarity index 100% rename from CONTRIBUTING.MD rename to docs/CONTRIBUTING.MD diff --git a/Deploy/ARMTemplates/computeGallery/Win11-Ent-Base-Image-FrontEnd-Docker-Template.json b/docs/index.md similarity index 100% rename from Deploy/ARMTemplates/computeGallery/Win11-Ent-Base-Image-FrontEnd-Docker-Template.json rename to docs/index.md