44 [string ]$outputUrlPrefix ,
55 [string ]$identityResourceId ,
66
7- # Optional parameters for deleting the VM's resource group on completion
7+ # Optional parameters
8+ [string ]$msgenDownloadUrl = " https://datasetmsgen.blob.core.windows.net/dataset/msgen-oss/msgen-oss.zip" ,
9+
10+ # Optional parameters for deleting the VM's resource group on completion
811 [string ]$subscriptionId = $null ,
912 [string ]$resourceGroupName = $null ,
1013 [string ]$vmName = $null
@@ -13,12 +16,23 @@ param (
1316$ErrorActionPreference = " Stop"
1417
1518$azCopyDownloadUrl = " https://aka.ms/downloadazcopy-v10-windows"
16- $azCopyInstallDir = " C:\azcopy"
17- $tempDir = " D:\temp"
18- $msgenDownloadUrl = " https://datasetmsgen.blob.core.windows.net/dataset/msgen-oss/msgen-oss.zip"
19+ $azCopyInstallDir = " C:\azcopy"
20+ $tempDir = $env: TEMP
1921$hg38m1xUrl = " https://datasetmsgen.blob.core.windows.net/dataset/hg38m1x/*"
2022$hg38m1xIdxUrl = " https://datasetmsgen.blob.core.windows.net/dataset/hg38m1x.idx/*"
2123$logsZipPath = " $tempDir \logs\logs.zip"
24+ $dotnetRuntimeUrl = " https://builds.dotnet.microsoft.com/dotnet/Runtime/9.0.6/dotnet-runtime-9.0.6-win-x64.exe"
25+ $dotnetRuntimeInstallerPath = " $tempDir \dotnet-runtime-9.0.6-win-x64.exe"
26+ $javaInstallerBinaryName = " zulu8.84.0.15-ca-jdk8.0.442-win_x64.msi"
27+ $javaInstallerPath = " $tempDir \$javaInstallerBinaryName "
28+ $javaDownloadUrl = " https://cdn.azul.com/zulu/bin/zulu8.84.0.15-ca-jdk8.0.442-win_x64.msi"
29+ $defaultJavaPath = " C:\java\bin\java.exe"
30+
31+ # Function to check if .NET 9 Runtime is installed
32+ function Is-DotNet9Installed {
33+ $runtimes = & dotnet -- list- runtimes 2> $null
34+ return $runtimes -match " 9\."
35+ }
2236
2337try {
2438 # Create directories if they don't exist
@@ -61,18 +75,52 @@ try {
6175 # Download input files
6276 Write-Host " Authenticating AZCOPY with the user-assigned managed identity..."
6377 & " $azCopyInstallDir \azcopy.exe" login -- identity -- identity- resource- id $identityResourceId
78+
6479
6580 Write-Host " Downloading input files..."
6681 & " $azCopyInstallDir \azcopy.exe" cp $inputUrl1 " $tempDir \inputs"
6782 if (! [string ]::IsNullOrEmpty($inputUrl2 )) {
6883 & " $azCopyInstallDir \azcopy.exe" cp $inputUrl2 " $tempDir \inputs"
6984 }
7085
86+ if (! (Test-Path $defaultJavaPath )) {
87+ Write-Host " Java not found, downloading installer..."
88+ (New-Object Net.WebClient).DownloadFile($javaDownloadUrl , $javaInstallerPath )
89+ Write-Host " Installing Java..."
90+ Start-Process - FilePath " msiexec.exe" - ArgumentList " /quiet /i `" $javaInstallerPath `" INSTALLDIR=C:\java\" - Wait
91+ if ($LASTEXITCODE -ne 0 ) { throw " Java installation failed. Exit code: $LASTEXITCODE " }
92+ Write-Host " Java installed successfully."
93+ } else {
94+ Write-Host " Java is already installed."
95+ }
96+
97+
7198 # Download and unzip msgen-oss
7299 Write-Host " Downloading msgen-oss..."
73100 & " $azCopyInstallDir \azcopy.exe" cp $msgenDownloadUrl " $tempDir " -- recursive
74101 Expand-Archive - Path " $tempDir \msgen-oss.zip" - DestinationPath " $tempDir \msgen" - Force
75102
103+ # Download needed dotnet version
104+ if (Is- DotNet9Installed) {
105+ Write-Host " .NET 9 runtime is already installed." - ForegroundColor Green
106+ } else {
107+ Write-Host " .NET 9 runtime not found. Installing..." - ForegroundColor Yellow
108+ Invoke-WebRequest - Uri $dotnetRuntimeUrl - OutFile $dotnetRuntimeInstallerPath
109+
110+ # Install silently (no UI)
111+ Start-Process - FilePath $dotnetRuntimeInstallerPath - ArgumentList " /install" , " /quiet" , " /norestart" - Wait
112+
113+ # Clean up
114+ Remove-Item $dotnetRuntimeInstallerPath
115+
116+ # Confirm installation
117+ if (Is- DotNet9Installed) {
118+ Write-Host " .NET 9 runtime was successfully installed." - ForegroundColor Green
119+ } else {
120+ Write-Host " Installation failed or .NET 9 runtime not detected." - ForegroundColor Red
121+ }
122+ }
123+
76124 # Run msgen-oss
77125 Write-Host " Running msgen-oss..."
78126 & " $tempDir \msgen\msgen-oss.exe" $tempDir " $tempDir \inputs" " $tempDir \outputs" " $tempDir \logs" " $tempDir \resources" " R=hg38m1x;GERC=GVCF;BGZIP=True"
@@ -104,53 +152,54 @@ try {
104152
105153 Write-Host " Completed genomics successfully."
106154
107- # Delete VM resouce group if set
108- if ($subscriptionId -ne $null -and $resourceGroupName -ne $null -and $vmName -ne $null ) {
109- Write-Host " Deleting this VM now..."
155+ } catch {
156+ Write-Host " An error occurred: $ ( $_.Exception.Message ) "
157+ exit 1
158+ }
110159
111- Write-Host " Installing Azure CLI..."
160+ # Delete VM resouce group if set
161+ if ($subscriptionId -ne $null -and $resourceGroupName -ne $null -and $vmName -ne $null ) {
162+ Write-Host " Deleting this VM now..."
112163
113- # Azure CLI MSI installer URL
114- $azureCliInstallerUrl = " https://aka.ms/installazurecliwindows"
115- $installerPath = " $env: TEMP \AzureCLIInstaller.msi"
164+ Write-Host " Installing Azure CLI..."
116165
117- # Download Azure CLI installer using WebClient
118- Write-Host " Downloading Azure CLI installer from $azureCliInstallerUrl ..."
119- $webClient = New-Object System.Net.WebClient
120- $webClient.DownloadFile ($azureCliInstallerUrl , $installerPath )
166+ # Azure CLI MSI installer URL
167+ $azureCliInstallerUrl = " https://aka.ms/installazurecliwindows"
168+ $installerPath = " $env: TEMP \AzureCLIInstaller.msi"
121169
122- # Install Azure CLI silently
123- Write-Host " Installing Azure CLI..."
124- Start-Process - FilePath " msiexec.exe" - ArgumentList " /I `" $installerPath `" /quiet /norestart" - Wait
170+ # Download Azure CLI installer using WebClient
171+ Write-Host " Downloading Azure CLI installer from $azureCliInstallerUrl ..."
172+ $webClient = New-Object System.Net.WebClient
173+ $webClient.DownloadFile ($azureCliInstallerUrl , $installerPath )
125174
126- # Cleanup the installer
127- Remove-Item - Path $installerPath - Force
128- Write-Host " Azure CLI installed successfully. "
175+ # Install Azure CLI silently
176+ Write-Host " Installing Azure CLI... "
177+ Start-Process - FilePath " msiexec.exe " - ArgumentList " /I `" $installerPath `" /quiet /norestart " - Wait
129178
130- # Add Azure CLI to PATH
131- $azPath = " C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin"
132- if (-not ($env: PATH -like " *$azPath *" )) {
133- $env: PATH += " ;$azPath "
134- }
179+ # Cleanup the installer
180+ Remove-Item - Path $installerPath - Force
181+ Write-Host " Azure CLI installed successfully."
135182
136- # Step 2: Authenticate using User Assigned Managed Identity (UAMI)
137- Write-Host " Authenticating using User Assigned Managed Identity..."
138- $loginResult = az login -- identity -- username $identityResourceId -- query ' [0].id' - o tsv
183+ # Add Azure CLI to PATH
184+ $azPath = " C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin"
185+ if (-not ($env: PATH -like " *$azPath *" )) {
186+ $env: PATH += " ;$azPath "
187+ }
139188
140- if ($LASTEXITCODE -ne 0 ) {
141- Write-Host " Failed to authenticate with the User Assigned Managed Identity. Exiting..."
142- exit 1
143- }
144- Write-Host " Authentication successful."
189+ # Step 2: Authenticate using User Assigned Managed Identity (UAMI)
190+ Write-Host " Authenticating using User Assigned Managed Identity..."
191+ $loginResult = az login -- identity -- resource- id $identityResourceId -- query ' [0].id' - o tsv
145192
146- az account set -- subscription $subscriptionId
193+ if ($LASTEXITCODE -ne 0 ) {
194+ Write-Host " Failed to authenticate with the User Assigned Managed Identity. Exiting..."
195+ exit 1
196+ }
197+ Write-Host " Authentication successful."
147198
148- Write-Host " Deleting the VM's resource group..."
149- az group delete -- name $resourceGroupName -- yes -- no- wait
199+ az account set -- subscription $subscriptionId
150200
151- Write-Host " VM resource group deletion initiated. Everything complete."
152- }
153- } catch {
154- Write-Host " An error occurred: $ ( $_.Exception.Message ) "
155- exit 1
156- }
201+ Write-Host " Deleting the VM's resource group..."
202+ az group delete -- name $resourceGroupName -- yes -- no- wait
203+
204+ Write-Host " VM resource group deletion initiated. Everything complete."
205+ }
0 commit comments