From 9501adc3db3d3b07bafc662de611f0170bd7fd84 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:41:14 +0200 Subject: [PATCH 01/22] Add Azure CLI command to set subscription ID This commit adds a new Azure CLI command to set the subscription ID in the DataOpsLogonScript.ps1 and installCAPI.sh scripts. This ensures that the correct subscription is used for subsequent commands. --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 1 + azure_jumpstart_arcbox/artifacts/installCAPI.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 002ac6aa8f..b60cb1d433 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -33,6 +33,7 @@ Connect-AzAccount -Credential $psCred -TenantId $Env:spnTenantId -ServicePrincip # Required for CLI commands Write-Header "Az CLI Login" az login --service-principal --username $Env:spnClientID --password $Env:spnClientSecret --tenant $Env:spnTenantId +az account set -s $Env:subscriptionId # Register Azure providers Write-Header "Registering Providers" diff --git a/azure_jumpstart_arcbox/artifacts/installCAPI.sh b/azure_jumpstart_arcbox/artifacts/installCAPI.sh index f981548505..b40e11e971 100644 --- a/azure_jumpstart_arcbox/artifacts/installCAPI.sh +++ b/azure_jumpstart_arcbox/artifacts/installCAPI.sh @@ -53,6 +53,8 @@ sudo -u $adminUsername az extension add --name k8s-extension echo "Log in to Azure" sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password $SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID subscriptionId=$(sudo -u $adminUsername az account show --query id --output tsv) +sudo -u $adminUsername az account set -s $subscriptionId + export AZURE_RESOURCE_GROUP=$(sudo -u $adminUsername az resource list --query "[?name=='$stagingStorageAccountName']".[resourceGroup] --resource-type "Microsoft.Storage/storageAccounts" -o tsv) az -v echo "" From e90c4f5fd84dc2f2de0d674f37be1068c7d67b7c Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:11:30 +0200 Subject: [PATCH 02/22] Add subscription ID retrieval and set active subscription --- azure_jumpstart_arcbox/artifacts/installK3s.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/azure_jumpstart_arcbox/artifacts/installK3s.sh b/azure_jumpstart_arcbox/artifacts/installK3s.sh index 2961029e8f..0417b1c1ce 100644 --- a/azure_jumpstart_arcbox/artifacts/installK3s.sh +++ b/azure_jumpstart_arcbox/artifacts/installK3s.sh @@ -78,6 +78,9 @@ sudo -u $adminUsername az extension add --name k8s-extension echo "" echo "Log in to Azure" sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password $SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID +subscriptionId=$(sudo -u $adminUsername az account show --query id --output tsv) +sudo -u $adminUsername az account set -s $subscriptionId + az -v echo "" From 726f3ce3762e91ecc3ea75dddc1a830a4d9aa869 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 19 Dec 2023 19:15:56 +0200 Subject: [PATCH 03/22] Update Arc version to 1.18.0 --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index b60cb1d433..fdd62b9550 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -193,7 +193,7 @@ foreach ($cluster in $clusters) { --auto-upgrade false ` --scope cluster ` --release-namespace arc ` - --version 1.25.0 ` + --version 1.18.0 ` --config Microsoft.CustomLocation.ServiceAccount=sa-bootstrapper Write-Host "`n" From 47a0fe11182391079a1f6b30fb45c5c8ddf4b904 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Mon, 25 Dec 2023 12:05:10 +0200 Subject: [PATCH 04/22] Update Arc version to 1.25.0 --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index fdd62b9550..b60cb1d433 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -193,7 +193,7 @@ foreach ($cluster in $clusters) { --auto-upgrade false ` --scope cluster ` --release-namespace arc ` - --version 1.18.0 ` + --version 1.25.0 ` --config Microsoft.CustomLocation.ServiceAccount=sa-bootstrapper Write-Host "`n" From f8a3f20f263e6e9601963cba6ca05d59df6fbc81 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Mon, 8 Jan 2024 08:44:13 +0200 Subject: [PATCH 05/22] Update PowerShell version to latest release --- azure_jumpstart_arcbox/artifacts/Bootstrap.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/azure_jumpstart_arcbox/artifacts/Bootstrap.ps1 b/azure_jumpstart_arcbox/artifacts/Bootstrap.ps1 index c4b26a4e3e..223d4d19d8 100644 --- a/azure_jumpstart_arcbox/artifacts/Bootstrap.ps1 +++ b/azure_jumpstart_arcbox/artifacts/Bootstrap.ps1 @@ -150,7 +150,6 @@ $url = "https://github.com/PowerShell/PowerShell/releases/latest" $latestVersion = (Invoke-WebRequest -UseBasicParsing -Uri $url).Content | Select-String -Pattern "v[0-9]+\.[0-9]+\.[0-9]+" | Select-Object -ExpandProperty Matches | Select-Object -ExpandProperty Value $downloadUrl = "https://github.com/PowerShell/PowerShell/releases/download/$latestVersion/PowerShell-$($latestVersion.Substring(1,5))-win-x64.msi" Invoke-WebRequest -UseBasicParsing -Uri $downloadUrl -OutFile .\PowerShell7.msi -msiexec.exe /package PowerShell7.msi /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1 USE_MU=1 ENABLE_MU=1 ADD_PATH=1 Start-Process msiexec.exe -Wait -ArgumentList '/I PowerShell7.msi /quiet ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ENABLE_PSREMOTING=1 REGISTER_MANIFEST=1 USE_MU=1 ENABLE_MU=1 ADD_PATH=1' Remove-Item .\PowerShell7.msi From 986130b5096699e9ee3741fbc184115fa863b53a Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:35:11 +0200 Subject: [PATCH 06/22] Add tests to verify infrastructure and display results on wallpaper using BGInfo --- .../artifacts/DataOpsLogonScript.ps1 | 20 +++++++++++++ .../artifacts/tests/dataops.tests.ps1 | 30 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 85773492b3..479e94b2b5 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -343,6 +343,26 @@ if ($null -ne (Get-ScheduledTask -TaskName "DataOpsLogonScript" -ErrorAction Sil Start-Sleep -Seconds 5 +Write-Header "Running tests to verify infrastructure" + +Invoke-Pester -Path "$Env:ArcBoxTestsDir\common.tests.ps1" -Output Detailed -PassThru -OutVariable tests_common +$tests_passed = $tests_common.Passed.Count +$tests_failed = $tests_common.Failed.Count + +Invoke-Pester -Path "$Env:ArcBoxTestsDir\dataops.tests.ps1" -Output Detailed -Output Detailed -PassThru -OutVariable tests_dataops +$tests_passed = $tests_passed + $tests_dataops.Passed.Count +$tests_failed = $tests_failed + $tests_dataops.Failed.Count + +Write-Output "Tests succeeded: $tests_passed" +Write-Output "Tests failed: $tests_failed" + +Write-Header "Adding deployment test results to wallpaper using BGInfo" + +Set-Content "$Env:windir\TEMP\arcbox-tests-succeeded.txt" $tests_passed +Set-Content "$Env:windir\TEMP\arcbox-tests-failed.txt" $tests_failed + +bginfo.exe $Env:ArcBoxTestsDir\arcbox-bginfo.bgi /timer:0 /NOLICPROMPT + # Executing the deployment logs bundle PowerShell script in a new window Write-Header "Uploading Log Bundle" Invoke-Expression 'cmd /c start Powershell -Command { diff --git a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 index e69de29bb2..9a8969141a 100644 --- a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 +++ b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 @@ -0,0 +1,30 @@ + +BeforeDiscovery { + + $capiArcDataClusterName = $env:capiArcDataClusterName + $aksArcClusterName = $env:aksArcClusterName + $aksdrArcClusterName = $env:aksdrArcClusterName + + $clusters = @($capiArcDataClusterName, $aksArcClusterName, $aksdrArcClusterName) + $dataControllers = @("${capiArcDataClusterName}-dc", "${aksArcClusterName}-dc", "${aksdrArcClusterName}-dc") + $sqlInstances = @("capi-sql", "aks-sql", "aks-dr-sql") + + $spnpassword = ConvertTo-SecureString $env:spnClientSecret -AsPlainText -Force + $spncredential = New-Object System.Management.Automation.PSCredential ($env:spnClientId, $spnpassword) + + $null = Connect-AzAccount -ServicePrincipal -Credential $spncredential -Tenant $env:spntenantId -Subscription $env:subscriptionId +} + +Describe "" -ForEach $clusters { + BeforeAll { + $cluster = $_ + } + It "Cluster exists" { + $clusterObject = Get-AzConnectedKubernetes -ClusterName $cluster -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId + $clusterObject | Should -Not -BeNullOrEmpty + } + It "Azure Arc Connected cluster is connected" { + $connectedCluster = Get-AzConnectedKubernetes -Name $cluster -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId + $connectedCluster.ConnectivityStatus | Should -Be "Connected" + } +} \ No newline at end of file From 6ed039a1d3145ca076261f4752e228d00182f0b5 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Mon, 15 Jan 2024 18:13:11 +0200 Subject: [PATCH 07/22] Remove unnecessary 'az account set' command --- azure_jumpstart_arcbox/artifacts/installCAPI.sh | 1 - azure_jumpstart_arcbox/artifacts/installK3s.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/installCAPI.sh b/azure_jumpstart_arcbox/artifacts/installCAPI.sh index b40e11e971..54f8d2765b 100644 --- a/azure_jumpstart_arcbox/artifacts/installCAPI.sh +++ b/azure_jumpstart_arcbox/artifacts/installCAPI.sh @@ -53,7 +53,6 @@ sudo -u $adminUsername az extension add --name k8s-extension echo "Log in to Azure" sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password $SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID subscriptionId=$(sudo -u $adminUsername az account show --query id --output tsv) -sudo -u $adminUsername az account set -s $subscriptionId export AZURE_RESOURCE_GROUP=$(sudo -u $adminUsername az resource list --query "[?name=='$stagingStorageAccountName']".[resourceGroup] --resource-type "Microsoft.Storage/storageAccounts" -o tsv) az -v diff --git a/azure_jumpstart_arcbox/artifacts/installK3s.sh b/azure_jumpstart_arcbox/artifacts/installK3s.sh index 0417b1c1ce..ccfa513ce9 100644 --- a/azure_jumpstart_arcbox/artifacts/installK3s.sh +++ b/azure_jumpstart_arcbox/artifacts/installK3s.sh @@ -79,7 +79,6 @@ echo "" echo "Log in to Azure" sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password $SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID subscriptionId=$(sudo -u $adminUsername az account show --query id --output tsv) -sudo -u $adminUsername az account set -s $subscriptionId az -v echo "" From 58de4c8f6cfa5c2a30801c8c87c8fc12ed078e63 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Wed, 17 Jan 2024 19:01:32 +0200 Subject: [PATCH 08/22] Add custom location and data controller variables This commit adds two new variables, $customLocation and $dataController, to the PowerShell script. These variables are used to store the custom location and data controller names for each cluster. This change enables the script to create custom locations and deploy the Azure Arc Data Controller on each cluster. --- .../artifacts/DataOpsLogonScript.ps1 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 479e94b2b5..10d796a6f6 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -181,6 +181,9 @@ $clusters | Foreach-Object -ThrottleLimit 5 -Parallel { $cluster = $_ $context = $cluster.context $clusterName = $cluster.clusterName + $customLocation = $cluster.customLocation + $dataController = $cluster.dataController + Start-Transcript -Path "$Env:ArcBoxLogsDir\DataController-$context.log" Write-Host "Deploying arc data services on $clusterName" Write-Host "`n" @@ -204,17 +207,17 @@ $clusters | Foreach-Object -ThrottleLimit 5 -Parallel { } while ($podStatus -eq "Nope") Write-Host "Bootstrapper pod is ready!" - $connectedClusterId = az connectedk8s show --name $cluster.clusterName --resource-group $Env:resourceGroup --query id -o tsv - $extensionId = az k8s-extension show --name arc-data-services --cluster-type connectedClusters --cluster-name $cluster.clusterName --resource-group $Env:resourceGroup --query id -o tsv + $connectedClusterId = az connectedk8s show --name $clusterName --resource-group $Env:resourceGroup --query id -o tsv + $extensionId = az k8s-extension show --name arc-data-services --cluster-type connectedClusters --cluster-name $clusterName --resource-group $Env:resourceGroup --query id -o tsv Start-Sleep -Seconds 10 - az customlocation create --name $cluster.customLocation --resource-group $Env:resourceGroup --namespace arc --host-resource-id $connectedClusterId --cluster-extension-ids $extensionId --kubeconfig $cluster.kubeConfig --only-show-errors + az customlocation create --name $customLocation --resource-group $Env:resourceGroup --namespace arc --host-resource-id $connectedClusterId --cluster-extension-ids $extensionId --kubeconfig $cluster.kubeConfig --only-show-errors Start-Sleep -Seconds 20 # Deploying the Azure Arc Data Controller $context = $cluster.context - $customLocationId = $(az customlocation show --name $cluster.customLocation --resource-group $Env:resourceGroup --query id -o tsv) + $customLocationId = $(az customlocation show --name $customLocation --resource-group $Env:resourceGroup --query id -o tsv) $workspaceId = $(az resource show --resource-group $Env:resourceGroup --name $Env:workspaceName --resource-type "Microsoft.OperationalInsights/workspaces" --query properties.customerId -o tsv) $workspaceKey = $(az monitor log-analytics workspace get-shared-keys --resource-group $Env:resourceGroup --workspace-name $Env:workspaceName --query primarySharedKey -o tsv) Copy-Item "$Env:ArcBoxDir\dataController.parameters.json" -Destination "$Env:ArcBoxDir\dataController-$context-stage.parameters.json" @@ -235,7 +238,7 @@ $clusters | Foreach-Object -ThrottleLimit 5 -Parallel { Write-Host "Deploying arc data controller on $clusterName" Write-Host "`n" - az deployment group create --resource-group $Env:resourceGroup --name $cluster.dataController --template-file "$Env:ArcBoxDir\dataController.json" --parameters "$Env:ArcBoxDir\dataController-$context-stage.parameters.json" + az deployment group create --resource-group $Env:resourceGroup --name $dataController --template-file "$Env:ArcBoxDir\dataController.json" --parameters "$Env:ArcBoxDir\dataController-$context-stage.parameters.json" Write-Host "`n" Do { From f71737dc0377c8c205aa4e64ae51ada28b3eeae4 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Wed, 17 Jan 2024 19:29:36 +0200 Subject: [PATCH 09/22] Update DataOpsLogonScript.ps1 to use variables for cluster name and data controller --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 10d796a6f6..ae617b33a8 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -264,10 +264,12 @@ $Env:WORKSPACE_ID = $(az resource show --resource-group $Env:resourceGroup --nam $Env:WORKSPACE_SHARED_KEY = $(az monitor log-analytics workspace get-shared-keys --resource-group $Env:resourceGroup --workspace-name $Env:workspaceName --query primarySharedKey -o tsv) foreach($cluster in $clusters){ - $Env:MSI_OBJECT_ID = (az k8s-extension show --resource-group $Env:resourceGroup --cluster-name $cluster.clusterName --cluster-type connectedClusters --name arc-data-services | convertFrom-json).identity.principalId + $clusterName = $cluster.clusterName + $dataController = $cluster.dataController + $Env:MSI_OBJECT_ID = (az k8s-extension show --resource-group $Env:resourceGroup --cluster-name $clusterName --cluster-type connectedClusters --name arc-data-services | convertFrom-json).identity.principalId az role assignment create --assignee $Env:MSI_OBJECT_ID --role 'Monitoring Metrics Publisher' --scope "/subscriptions/$Env:subscriptionId/resourceGroups/$Env:resourceGroup" - az arcdata dc update --name $cluster.dataController --resource-group $Env:resourceGroup --auto-upload-metrics true - az arcdata dc update --name $cluster.dataController --resource-group $Env:resourceGroup --auto-upload-logs true + az arcdata dc update --name $dataController --resource-group $Env:resourceGroup --auto-upload-metrics true + az arcdata dc update --name $dataController --resource-group $Env:resourceGroup --auto-upload-logs true } Write-Header "Deploying App" From 3de5ccb8b83954eed59d492f19f92a5bef1e85de Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Thu, 18 Jan 2024 08:55:17 +0200 Subject: [PATCH 10/22] Refactor test script invocation in DataOpsLogonScript.ps1 --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index ae617b33a8..1eb46b06b0 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -354,7 +354,7 @@ Invoke-Pester -Path "$Env:ArcBoxTestsDir\common.tests.ps1" -Output Detailed -Pas $tests_passed = $tests_common.Passed.Count $tests_failed = $tests_common.Failed.Count -Invoke-Pester -Path "$Env:ArcBoxTestsDir\dataops.tests.ps1" -Output Detailed -Output Detailed -PassThru -OutVariable tests_dataops +Invoke-Pester -Path "$Env:ArcBoxTestsDir\dataops.tests.ps1" -Output Detailed -PassThru -OutVariable tests_dataops $tests_passed = $tests_passed + $tests_dataops.Passed.Count $tests_failed = $tests_failed + $tests_dataops.Failed.Count From ec624671638960b948b1e67a774e208bd4e408b4 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:19:43 +0200 Subject: [PATCH 11/22] Add OpenSSL Light package using WinGet --- azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml b/azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml index 57d3cf9aed..d1bb0659d1 100644 --- a/azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml +++ b/azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml @@ -44,4 +44,12 @@ properties: settings: id: Microsoft.AzureDataStudio source: winget + - resource: Microsoft.WinGet.DSC/WinGetPackage + id: ShiningLight.OpenSSL.Light + directives: + description: Install OpenSSL light + settings: + id: ShiningLight.OpenSSL.Light + source: winget + configurationVersion: 0.2.0 \ No newline at end of file From 39840dac01c739773c8c70e1086d90616c3df52a Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:46:53 +0200 Subject: [PATCH 12/22] Update Azure CLI commands and remove unused code --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 1 - azure_jumpstart_arcbox/artifacts/installK3s.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 1eb46b06b0..807b2b9b48 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -33,7 +33,6 @@ Connect-AzAccount -Credential $psCred -TenantId $Env:spnTenantId -ServicePrincip # Required for CLI commands Write-Header "Az CLI Login" az login --service-principal --username $Env:spnClientID --password $Env:spnClientSecret --tenant $Env:spnTenantId -az account set -s $Env:subscriptionId # Register Azure providers Write-Header "Registering Providers" diff --git a/azure_jumpstart_arcbox/artifacts/installK3s.sh b/azure_jumpstart_arcbox/artifacts/installK3s.sh index ccfa513ce9..2af78f7395 100644 --- a/azure_jumpstart_arcbox/artifacts/installK3s.sh +++ b/azure_jumpstart_arcbox/artifacts/installK3s.sh @@ -78,7 +78,6 @@ sudo -u $adminUsername az extension add --name k8s-extension echo "" echo "Log in to Azure" sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password $SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID -subscriptionId=$(sudo -u $adminUsername az account show --query id --output tsv) az -v echo "" From 7bf04d301678b3f3a697da9387437a6ab20c5bde Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:47:53 +0200 Subject: [PATCH 13/22] Remove unnecessary blank line and print Azure CLI version --- azure_jumpstart_arcbox/artifacts/installK3s.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/azure_jumpstart_arcbox/artifacts/installK3s.sh b/azure_jumpstart_arcbox/artifacts/installK3s.sh index 2af78f7395..2961029e8f 100644 --- a/azure_jumpstart_arcbox/artifacts/installK3s.sh +++ b/azure_jumpstart_arcbox/artifacts/installK3s.sh @@ -78,7 +78,6 @@ sudo -u $adminUsername az extension add --name k8s-extension echo "" echo "Log in to Azure" sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password $SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID - az -v echo "" From bf841b0a1cfc12709940f000817217c63c864a2d Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:48:39 +0200 Subject: [PATCH 14/22] Update Azure CLI versions and set subscription ID --- azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 | 5 +++-- azure_jumpstart_arcbox/artifacts/installK3s.sh | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 7e8e6fb0f0..1eb46b06b0 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -32,7 +32,8 @@ Connect-AzAccount -Credential $psCred -TenantId $Env:spnTenantId -ServicePrincip # Required for CLI commands Write-Header "Az CLI Login" -az login --service-principal --username $Env:spnClientID --password=$Env:spnClientSecret --tenant $Env:spnTenantId +az login --service-principal --username $Env:spnClientID --password $Env:spnClientSecret --tenant $Env:spnTenantId +az account set -s $Env:subscriptionId # Register Azure providers Write-Header "Registering Providers" @@ -194,7 +195,7 @@ $clusters | Foreach-Object -ThrottleLimit 5 -Parallel { --auto-upgrade false ` --scope cluster ` --release-namespace arc ` - --version 1.26.0 ` + --version 1.25.0 ` --config Microsoft.CustomLocation.ServiceAccount=sa-bootstrapper Write-Host "`n" diff --git a/azure_jumpstart_arcbox/artifacts/installK3s.sh b/azure_jumpstart_arcbox/artifacts/installK3s.sh index 27832a807d..3ec915d1ac 100644 --- a/azure_jumpstart_arcbox/artifacts/installK3s.sh +++ b/azure_jumpstart_arcbox/artifacts/installK3s.sh @@ -77,7 +77,8 @@ sudo -u $adminUsername az extension add --name k8s-extension echo "" echo "Log in to Azure" -sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password=$SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID +sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password $SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID +subscriptionId=$(sudo -u $adminUsername az account show --query id --output tsv) az -v echo "" From b1a4c78dd54754803515d261d364ee7ab181266c Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:55:43 +0200 Subject: [PATCH 15/22] Add OpenSSL to PATH environment variable --- azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 | 7 +++++++ azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 index d652cd1328..2e2eb57d7a 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 @@ -16,6 +16,13 @@ $certPassword = ConvertTo-SecureString -String $password -Force -AsPlainText Export-PfxCertificate -Cert "cert:\CurrentUser\My\$($cert.Thumbprint)" -FilePath "$Env:TempDir\$CName.pfx" -Password $certPassword Import-PfxCertificate -FilePath "$Env:TempDir\$CName.pfx" -CertStoreLocation Cert:\LocalMachine\Root -Password $certPassword +# Add OpenSSL to path environment variable +$openSSL = "C:\Program Files\FireDaemon OpenSSL 3\bin" +$currentPathVariable = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine) +$newPathVariable = $currentPathVariable + ";" + $openSSL +[Environment]::SetEnvironmentVariable("PATH", $newPathVariable, [EnvironmentVariableTarget]::Machine) + + openssl pkcs12 -in "$Env:TempDir\$CName.pfx" -nocerts -out "$Env:TempDir\$CName.key" -password pass:$password -passout pass:$password openssl pkcs12 -in "$Env:TempDir\$CName.pfx" -clcerts -nokeys -out "$Env:TempDir\$CName.crt" -password pass:$password openssl rsa -in "$Env:TempDir\$CName.key" -out "$Env:TempDir\$CName-dec.key" -passin pass:$password diff --git a/azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml b/azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml index d1bb0659d1..748107de36 100644 --- a/azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml +++ b/azure_jumpstart_arcbox/artifacts/dsc/dataops.dsc.yml @@ -45,11 +45,11 @@ properties: id: Microsoft.AzureDataStudio source: winget - resource: Microsoft.WinGet.DSC/WinGetPackage - id: ShiningLight.OpenSSL.Light + id: FireDaemon.OpenSSL directives: - description: Install OpenSSL light + description: Install OpenSSL settings: - id: ShiningLight.OpenSSL.Light + id: FireDaemon.OpenSSL source: winget configurationVersion: 0.2.0 \ No newline at end of file From fdc7f54b18f6794fce82b96504ea93a539958511 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:02:16 +0200 Subject: [PATCH 16/22] Fix Azure subscription issue --- azure_jumpstart_arcbox/artifacts/installCAPI.sh | 2 +- azure_jumpstart_arcbox/artifacts/installK3s.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/azure_jumpstart_arcbox/artifacts/installCAPI.sh b/azure_jumpstart_arcbox/artifacts/installCAPI.sh index 90b91df034..7b06c2a37a 100644 --- a/azure_jumpstart_arcbox/artifacts/installCAPI.sh +++ b/azure_jumpstart_arcbox/artifacts/installCAPI.sh @@ -53,7 +53,7 @@ sudo -u $adminUsername az extension add --name k8s-extension echo "Log in to Azure" sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password=$SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID subscriptionId=$(sudo -u $adminUsername az account show --query id --output tsv) - +sudo -u $adminUsername az account set -s $subscriptionId export AZURE_RESOURCE_GROUP=$(sudo -u $adminUsername az resource list --query "[?name=='$stagingStorageAccountName']".[resourceGroup] --resource-type "Microsoft.Storage/storageAccounts" -o tsv) az -v echo "" diff --git a/azure_jumpstart_arcbox/artifacts/installK3s.sh b/azure_jumpstart_arcbox/artifacts/installK3s.sh index 3ec915d1ac..2ef7db3bcb 100644 --- a/azure_jumpstart_arcbox/artifacts/installK3s.sh +++ b/azure_jumpstart_arcbox/artifacts/installK3s.sh @@ -79,6 +79,7 @@ echo "" echo "Log in to Azure" sudo -u $adminUsername az login --service-principal --username $SPN_CLIENT_ID --password $SPN_CLIENT_SECRET --tenant $SPN_TENANT_ID subscriptionId=$(sudo -u $adminUsername az account show --query id --output tsv) +sudo -u $adminUsername az account set -s $subscriptionId az -v echo "" From ca5579cade447514532dc53c78afb982a4051044 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Sun, 28 Jan 2024 11:12:07 +0200 Subject: [PATCH 17/22] Refactor test execution in DataOpsLogonScript.ps1 --- .../artifacts/DataOpsLogonScript.ps1 | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 1eb46b06b0..ec2d3a3e13 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -350,23 +350,7 @@ Start-Sleep -Seconds 5 Write-Header "Running tests to verify infrastructure" -Invoke-Pester -Path "$Env:ArcBoxTestsDir\common.tests.ps1" -Output Detailed -PassThru -OutVariable tests_common -$tests_passed = $tests_common.Passed.Count -$tests_failed = $tests_common.Failed.Count - -Invoke-Pester -Path "$Env:ArcBoxTestsDir\dataops.tests.ps1" -Output Detailed -PassThru -OutVariable tests_dataops -$tests_passed = $tests_passed + $tests_dataops.Passed.Count -$tests_failed = $tests_failed + $tests_dataops.Failed.Count - -Write-Output "Tests succeeded: $tests_passed" -Write-Output "Tests failed: $tests_failed" - -Write-Header "Adding deployment test results to wallpaper using BGInfo" - -Set-Content "$Env:windir\TEMP\arcbox-tests-succeeded.txt" $tests_passed -Set-Content "$Env:windir\TEMP\arcbox-tests-failed.txt" $tests_failed - -bginfo.exe $Env:ArcBoxTestsDir\arcbox-bginfo.bgi /timer:0 /NOLICPROMPT +& "$Env:ArcBoxTestsDir\Invoke-Test.ps1" # Executing the deployment logs bundle PowerShell script in a new window Write-Header "Uploading Log Bundle" From 05fb2540c340dbf2806b936ed45aa7a20581f046 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:18:27 +0200 Subject: [PATCH 18/22] Add Az.CustomLocation module and update OpenSSL path --- .../artifacts/Bootstrap.ps1 | 2 +- .../artifacts/DataOpsAppScript.ps1 | 9 +---- .../artifacts/DataOpsLogonScript.ps1 | 7 ++++ .../artifacts/tests/Invoke-Test.ps1 | 2 +- .../artifacts/tests/dataops.tests.ps1 | 34 ++++++++++++++++++- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/Bootstrap.ps1 b/azure_jumpstart_arcbox/artifacts/Bootstrap.ps1 index 7975fbd6ea..51d8a4a5db 100644 --- a/azure_jumpstart_arcbox/artifacts/Bootstrap.ps1 +++ b/azure_jumpstart_arcbox/artifacts/Bootstrap.ps1 @@ -126,7 +126,7 @@ Resize-Partition -DriveLetter C -Size $(Get-PartitionSupportedSize -DriveLetter Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force Install-Module -Name Microsoft.PowerShell.PSResourceGet -Force -$modules = @("Az", "Az.ConnectedMachine", "Azure.Arc.Jumpstart.Common", "Posh-SSH", "Pester") +$modules = @("Az", "Az.ConnectedMachine", "Az.ConnectedKubernetes", "Az.CustomLocation", "Azure.Arc.Jumpstart.Common", "Posh-SSH", "Pester") foreach ($module in $modules) { Install-PSResource -Name $module -Scope AllUsers -Quiet -AcceptLicense -TrustRepository diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 index 2e2eb57d7a..dbfa3c8cdf 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 @@ -16,15 +16,8 @@ $certPassword = ConvertTo-SecureString -String $password -Force -AsPlainText Export-PfxCertificate -Cert "cert:\CurrentUser\My\$($cert.Thumbprint)" -FilePath "$Env:TempDir\$CName.pfx" -Password $certPassword Import-PfxCertificate -FilePath "$Env:TempDir\$CName.pfx" -CertStoreLocation Cert:\LocalMachine\Root -Password $certPassword -# Add OpenSSL to path environment variable -$openSSL = "C:\Program Files\FireDaemon OpenSSL 3\bin" -$currentPathVariable = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine) -$newPathVariable = $currentPathVariable + ";" + $openSSL -[Environment]::SetEnvironmentVariable("PATH", $newPathVariable, [EnvironmentVariableTarget]::Machine) - - openssl pkcs12 -in "$Env:TempDir\$CName.pfx" -nocerts -out "$Env:TempDir\$CName.key" -password pass:$password -passout pass:$password -openssl pkcs12 -in "$Env:TempDir\$CName.pfx" -clcerts -nokeys -out "$Env:TempDir\$CName.crt" -password pass:$password +openssl pkcs12 -in "$Env:TempDir\$CName.pfx" -clcerts -nokeys -out "$Env:TempDir\$CName.crt" -password pass:$password openssl rsa -in "$Env:TempDir\$CName.key" -out "$Env:TempDir\$CName-dec.key" -passin pass:$password Write-Header "Creating Ingress Controller" diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index ec2d3a3e13..456b6a3da5 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -273,6 +273,13 @@ foreach($cluster in $clusters){ } Write-Header "Deploying App" + +# Add OpenSSL to path environment variable +$openSSL = "C:\Program Files\FireDaemon OpenSSL 3\bin" +$currentPathVariable = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine) +$newPathVariable = $currentPathVariable + ";" + $openSSL +[Environment]::SetEnvironmentVariable("PATH", $newPathVariable, [EnvironmentVariableTarget]::Machine) + # Deploy App & "$Env:ArcBoxDir\DataOpsAppScript.ps1" diff --git a/azure_jumpstart_arcbox/artifacts/tests/Invoke-Test.ps1 b/azure_jumpstart_arcbox/artifacts/tests/Invoke-Test.ps1 index f672cf54db..bf0fb48323 100644 --- a/azure_jumpstart_arcbox/artifacts/tests/Invoke-Test.ps1 +++ b/azure_jumpstart_arcbox/artifacts/tests/Invoke-Test.ps1 @@ -12,7 +12,7 @@ switch ($env:flavor) { $tests_failed = $tests_failed + $tests_devops.Failed.Count } 'DataOps' { - Invoke-Pester -Path "$Env:ArcBoxTestsDir\dataops.tests.ps1" -Output Detailed -Output Detailed -PassThru -OutVariable tests_dataops + Invoke-Pester -Path "$Env:ArcBoxTestsDir\dataops.tests.ps1" -Output Detailed -PassThru -OutVariable tests_dataops $tests_passed = $tests_passed + $tests_dataops.Passed.Count $tests_failed = $tests_failed + $tests_dataops.Failed.Count } diff --git a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 index 9a8969141a..74edfdd8ef 100644 --- a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 +++ b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 @@ -6,6 +6,7 @@ BeforeDiscovery { $aksdrArcClusterName = $env:aksdrArcClusterName $clusters = @($capiArcDataClusterName, $aksArcClusterName, $aksdrArcClusterName) + $customLocations = @("${capiArcDataClusterName}-cl", "${aksArcClusterName}-cl", "${aksdrArcClusterName}-cl") $dataControllers = @("${capiArcDataClusterName}-dc", "${aksArcClusterName}-dc", "${aksdrArcClusterName}-dc") $sqlInstances = @("capi-sql", "aks-sql", "aks-dr-sql") @@ -27,4 +28,35 @@ Describe "" -ForEach $clusters { $connectedCluster = Get-AzConnectedKubernetes -Name $cluster -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId $connectedCluster.ConnectivityStatus | Should -Be "Connected" } -} \ No newline at end of file +} + +Describe "" -ForEach $customLocations { + BeforeAll { + $customLocation = $_ + } + It "Custom Location exists" { + $customLocationObject = Get-AzCustomLocation -Name $customLocation -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId + $customLocationObject | Should -Not -BeNullOrEmpty + } + It "Custom Location is connected" { + $customLocationObject = Get-AzCustomLocation -Name $customLocation -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId + $customLocationObject.ProvisioningState | Should -Be "Succeeded" + } +} + +<# +Describe "" -ForEach $dataController { + BeforeAll { + $dataController = $_ + } + It "Data Controller exists" { + az arcdata dc list --resource-group sb-arcbox --query "[].{name:name,state:properties.k8SRaw.status.state}" + $dataControllerObject = Get-AzDataController -Name $dataController -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId + $dataControllerObject | Should -Not -BeNullOrEmpty + } + It "Data Controller is connected" { + $dataControllerObject = Get-AzDataController -Name $dataController -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId + $dataControllerObject.ProvisioningState | Should -Be "Succeeded" + } +} +#> \ No newline at end of file From d93f676e535c041b8a7bd9e65c3ca605461cf886 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 30 Jan 2024 14:12:20 +0200 Subject: [PATCH 19/22] Updated SQL instance names and added tests for SQL Managed Instances --- .../artifacts/tests/dataops.tests.ps1 | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 index 74edfdd8ef..3ac9686994 100644 --- a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 +++ b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 @@ -8,7 +8,7 @@ BeforeDiscovery { $clusters = @($capiArcDataClusterName, $aksArcClusterName, $aksdrArcClusterName) $customLocations = @("${capiArcDataClusterName}-cl", "${aksArcClusterName}-cl", "${aksdrArcClusterName}-cl") $dataControllers = @("${capiArcDataClusterName}-dc", "${aksArcClusterName}-dc", "${aksdrArcClusterName}-dc") - $sqlInstances = @("capi-sql", "aks-sql", "aks-dr-sql") + $sqlMiInstances = @("capi-sql", "aks-sql", "aks-dr-sql") $spnpassword = ConvertTo-SecureString $env:spnClientSecret -AsPlainText -Force $spncredential = New-Object System.Management.Automation.PSCredential ($env:spnClientId, $spnpassword) @@ -44,19 +44,30 @@ Describe "" -ForEach $customLocations { } } -<# -Describe "" -ForEach $dataController { +Describe "" -ForEach $dataControllers { BeforeAll { $dataController = $_ } It "Data Controller exists" { - az arcdata dc list --resource-group sb-arcbox --query "[].{name:name,state:properties.k8SRaw.status.state}" - $dataControllerObject = Get-AzDataController -Name $dataController -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId - $dataControllerObject | Should -Not -BeNullOrEmpty + $dataControllerObject = az arcdata dc status show --resource-group $env:resourceGroup --name $dataController --query "{name:name,state:properties.k8SRaw.status.state}" + $dataControllerObject.Name | Should -Not -BeNullOrEmpty } It "Data Controller is connected" { - $dataControllerObject = Get-AzDataController -Name $dataController -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId - $dataControllerObject.ProvisioningState | Should -Be "Succeeded" + $dataControllerObject = az arcdata dc status show --resource-group $env:resourceGroup --name $dataController --query "{name:name,state:properties.k8SRaw.status.state}" + $dataControllerObject.State | Should -Be "Ready" } } -#> \ No newline at end of file + +Describe "" -ForEach $sqlMiInstances { + BeforeAll { + $sqlMiInstance = $_ + } + It "SQL Managed Instance exists" { + $sqlMiInstanceObject = az sql mi-arc show --resource-group $env:resourceGroup --name $sqlMiInstance --query "{name:name,state:properties.status}" + $sqlMiInstanceObject.Name | Should -Not -BeNullOrEmpty + } + It "SQL Managed Instance is connected" { + $sqlMiInstanceObject = az sql mi-arc show --resource-group $env:resourceGroup --name $sqlMiInstance --query "{name:name,state:properties.status}" + $sqlMiInstanceObject.State | Should -Be "Ready" + } +} \ No newline at end of file From c0a0574ef6bcb723c80a55c103da61c81d3a703f Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:57:08 +0200 Subject: [PATCH 20/22] Add OpenSSL to path environment variable and update tests --- .../artifacts/DataOpsAppScript.ps1 | 6 ++++ .../artifacts/DataOpsLogonScript.ps1 | 7 +--- .../artifacts/tests/dataops.tests.ps1 | 36 +++++++++++++------ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 index dbfa3c8cdf..1c59504efa 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 @@ -10,6 +10,12 @@ $sqlInstance = "capi" Start-Transcript -Path $Env:ArcBoxLogsDir\DataOpsAppScript.log +# Add OpenSSL to path environment variable +$openSSL = "C:\Program Files\FireDaemon OpenSSL 3\bin" +$currentPathVariable = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine) +$newPathVariable = $currentPathVariable + ";" + $openSSL +[Environment]::SetEnvironmentVariable("PATH", $newPathVariable, [EnvironmentVariableTarget]::Machine) + Write-Host "Generating a TLS Certificate" $cert = New-SelfSignedCertificate -DnsName $certdns -KeyAlgorithm RSA -KeyLength 2048 -NotAfter (Get-Date).AddYears(1) -CertStoreLocation "Cert:\CurrentUser\My" $certPassword = ConvertTo-SecureString -String $password -Force -AsPlainText diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 index 456b6a3da5..f590e78197 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsLogonScript.ps1 @@ -2,6 +2,7 @@ $Env:ArcBoxDir = "C:\ArcBox" $Env:ArcBoxLogsDir = "C:\ArcBox\Logs" $Env:ArcBoxVMDir = "$Env:ArcBoxDir\Virtual Machines" $Env:ArcBoxIconDir = "C:\ArcBox\Icons" +$Env:ArcBoxTestsDir = "$Env:ArcBoxDir\Tests" $clusters = @( [pscustomobject]@{clusterName = $Env:capiArcDataClusterName; dataController = "$Env:capiArcDataClusterName-dc" ; customLocation = "$Env:capiArcDataClusterName-cl" ; storageClassName = 'managed-premium' ; licenseType = 'LicenseIncluded' ; context = 'capi' ; kubeConfig = "C:\Users\$Env:adminUsername\.kube\config-capi" } @@ -274,12 +275,6 @@ foreach($cluster in $clusters){ Write-Header "Deploying App" -# Add OpenSSL to path environment variable -$openSSL = "C:\Program Files\FireDaemon OpenSSL 3\bin" -$currentPathVariable = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine) -$newPathVariable = $currentPathVariable + ";" + $openSSL -[Environment]::SetEnvironmentVariable("PATH", $newPathVariable, [EnvironmentVariableTarget]::Machine) - # Deploy App & "$Env:ArcBoxDir\DataOpsAppScript.ps1" diff --git a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 index 3ac9686994..8a817c0c39 100644 --- a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 +++ b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 @@ -9,11 +9,13 @@ BeforeDiscovery { $customLocations = @("${capiArcDataClusterName}-cl", "${aksArcClusterName}-cl", "${aksdrArcClusterName}-cl") $dataControllers = @("${capiArcDataClusterName}-dc", "${aksArcClusterName}-dc", "${aksdrArcClusterName}-dc") $sqlMiInstances = @("capi-sql", "aks-sql", "aks-dr-sql") + $drPartners = @("capi-sql", "aks-dr-sql") $spnpassword = ConvertTo-SecureString $env:spnClientSecret -AsPlainText -Force $spncredential = New-Object System.Management.Automation.PSCredential ($env:spnClientId, $spnpassword) $null = Connect-AzAccount -ServicePrincipal -Credential $spncredential -Tenant $env:spntenantId -Subscription $env:subscriptionId + az config set extension.use_dynamic_install=yes_without_prompt } Describe "" -ForEach $clusters { @@ -49,25 +51,39 @@ Describe "" -ForEach $dataControllers { $dataController = $_ } It "Data Controller exists" { - $dataControllerObject = az arcdata dc status show --resource-group $env:resourceGroup --name $dataController --query "{name:name,state:properties.k8SRaw.status.state}" - $dataControllerObject.Name | Should -Not -BeNullOrEmpty + $dataControllerObject = $(az arcdata dc status show --resource-group $env:resourceGroup --name $dataController --query "{name:name,state:properties.k8SRaw.status.state}") + ($dataControllerObject | ConvertFrom-Json).Name | Should -Not -BeNullOrEmpty } It "Data Controller is connected" { - $dataControllerObject = az arcdata dc status show --resource-group $env:resourceGroup --name $dataController --query "{name:name,state:properties.k8SRaw.status.state}" - $dataControllerObject.State | Should -Be "Ready" + $dataControllerObject = $(az arcdata dc status show --resource-group $env:resourceGroup --name $dataController --query "{name:name,state:properties.k8SRaw.status.state}") + ($dataControllerObject | ConvertFrom-Json).State | Should -Be "Ready" } } -Describe "" -ForEach $sqlMiInstances { +Describe "" -ForEach $sqlMiInstances { BeforeAll { - $sqlMiInstance = $_ + $sqlInstance = $_ } It "SQL Managed Instance exists" { - $sqlMiInstanceObject = az sql mi-arc show --resource-group $env:resourceGroup --name $sqlMiInstance --query "{name:name,state:properties.status}" - $sqlMiInstanceObject.Name | Should -Not -BeNullOrEmpty + $sqlMiInstanceObject = $(az sql mi-arc show --resource-group $env:resourceGroup --name $sqlInstance --query "{name:name,state:properties.k8SRaw.status.state}") + ($sqlMiInstanceObject| ConvertFrom-Json).Name | Should -Not -BeNullOrEmpty } It "SQL Managed Instance is connected" { - $sqlMiInstanceObject = az sql mi-arc show --resource-group $env:resourceGroup --name $sqlMiInstance --query "{name:name,state:properties.status}" - $sqlMiInstanceObject.State | Should -Be "Ready" + $sqlMiInstanceObject = $(az sql mi-arc show --resource-group $env:resourceGroup --name $sqlInstance --query "{name:name,state:properties.k8SRaw.status.state}") + ($sqlMiInstanceObject| ConvertFrom-Json).State | Should -Be "Ready" + } +} + +Describe "" -ForEach $drPartners{ + BeforeAll { + $drPartner = $_ + } + It "DR configuration exists" { + $drConfig = $(az sql instance-failover-group-arc list --resource-group $env:resourceGroup --mi $drPartner) + $drConfig | Should -Not -Be "Found 0 failover group(s)." + } + It "DR configuration is healthy" { + $drConfig = $(az sql mi-arc show --resource-group $env:resourceGroup --name $drPartner --query "{name:name,state:properties.k8SRaw.status.highAvailability.healthState}") + ($drConfig| ConvertFrom-Json).state | Should -Be "Ok" } } \ No newline at end of file From c20be12a75d96554788f4392f31b5001987d0b10 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:03:54 +0200 Subject: [PATCH 21/22] Update OpenSSL path in DataOpsAppScript.ps1 --- azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 b/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 index 1c59504efa..6fb859b40f 100644 --- a/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 +++ b/azure_jumpstart_arcbox/artifacts/DataOpsAppScript.ps1 @@ -12,9 +12,9 @@ Start-Transcript -Path $Env:ArcBoxLogsDir\DataOpsAppScript.log # Add OpenSSL to path environment variable $openSSL = "C:\Program Files\FireDaemon OpenSSL 3\bin" -$currentPathVariable = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine) +$currentPathVariable = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Process) $newPathVariable = $currentPathVariable + ";" + $openSSL -[Environment]::SetEnvironmentVariable("PATH", $newPathVariable, [EnvironmentVariableTarget]::Machine) +[Environment]::SetEnvironmentVariable("PATH", $newPathVariable, [EnvironmentVariableTarget]::Process) Write-Host "Generating a TLS Certificate" $cert = New-SelfSignedCertificate -DnsName $certdns -KeyAlgorithm RSA -KeyLength 2048 -NotAfter (Get-Date).AddYears(1) -CertStoreLocation "Cert:\CurrentUser\My" From c63454d4750716d6b978f2fe7d77fb3b05f8b165 Mon Sep 17 00:00:00 2001 From: Seif Bassem <38246040+sebassem@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:08:29 +0200 Subject: [PATCH 22/22] Add tests for VM and Azure Arc Connected Machine --- .../artifacts/tests/dataops.tests.ps1 | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 index 8a817c0c39..be45c771bf 100644 --- a/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 +++ b/azure_jumpstart_arcbox/artifacts/tests/dataops.tests.ps1 @@ -10,6 +10,7 @@ BeforeDiscovery { $dataControllers = @("${capiArcDataClusterName}-dc", "${aksArcClusterName}-dc", "${aksdrArcClusterName}-dc") $sqlMiInstances = @("capi-sql", "aks-sql", "aks-dr-sql") $drPartners = @("capi-sql", "aks-dr-sql") + $VMs = @("ArcBox-SQL") $spnpassword = ConvertTo-SecureString $env:spnClientSecret -AsPlainText -Force $spncredential = New-Object System.Management.Automation.PSCredential ($env:spnClientId, $spnpassword) @@ -86,4 +87,26 @@ Describe "" -ForEach $drPartners{ $drConfig = $(az sql mi-arc show --resource-group $env:resourceGroup --name $drPartner --query "{name:name,state:properties.k8SRaw.status.highAvailability.healthState}") ($drConfig| ConvertFrom-Json).state | Should -Be "Ok" } +} + +Describe "" -ForEach $VMs { + BeforeAll { + $vm = $_ + } + It "VM exists" { + $vmobject = Get-VM -Name $vm + $vmobject | Should -Not -BeNullOrEmpty + } + It "VM is running" { + $vmobject = Get-VM -Name $vm + $vmobject.State | Should -Be "Running" + } + It "Azure Arc Connected Machine exists" { + $connectedMachine = Get-AzConnectedMachine -Name $vm -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId + $connectedMachine | Should -Not -BeNullOrEmpty + } + It "Azure Arc Connected Machine is connected" { + $connectedMachine = Get-AzConnectedMachine -Name $vm -ResourceGroupName $env:resourceGroup -SubscriptionId $env:subscriptionId + $connectedMachine.Status | Should -Be "Connected" + } } \ No newline at end of file