I need to install IIS, NodeJS and SQL Server on a Azure VM. With 4 GB memory on a VM, I’m getting a out-of-memory error. Memory for the Azure VM was increased to 16 GB and error is still occurring.
{
"builders": [{
"type": "azure-arm",
"client_id": "abc",
"client_secret": "abc",
"tenant_id": "abc",
"subscription_id": "abc",
"name": "myVM",
"managed_image_resource_group_name": "packer",
"managed_image_name": "WINDOWS2019C",
"os_type": "Windows",
"image_publisher": "MicrosoftWindowsServer",
"image_offer": "WindowsServer",
"image_sku": "2016-Datacenter",
"communicator": "winrm",
"winrm_use_ssl": true,
"winrm_insecure": true,
"winrm_timeout": "5m",
"winrm_username": "packer",
"azure_tags": {
"dept": "NA",
"task": "Packer Demo"
},
"location": "East US",
"vm_size": "Standard_D2_v2"
}],
"provisioners": [{
"type": "powershell",
"script": "./MyPowerShellScript.ps1"
}]}
Powershell:
Invoke-RestMethod -Uri nodejs.org/dist/v10.16.3/node-v10.16.3-x64.msi -OutFile node.msi;
msiexec /i node.msi /quiet;
Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature
$webClient = New-Object System.Net.WebClient
$webURL = “http://sqlpackagedownloadbucket.s3.ap-south-1.amazonaws.com/SQLEXPRADV.zip”
$filePath = “.\SQLEXPRADV.zip”
$Webclient.DownloadFile($webURL, $filePath)
Start-Sleep -s 120
Expand-Archive -LiteralPath SQLEXPRADV.zip -DestinationPath .;
Start-Sleep -s 120
DISM.exe /online /enable-feature /all /featurename:NetFx3;
Start-Sleep -s 120
cd SQLEXPRADV_x64_ENU;
.\SETUP.EXE /Q /IAcceptSQLServerLicenseTerms /ACTION=install /UpdateEnabled=False /FEATURES=SQL /INSTANCENAME=SQL14 /SQLSVCACCOUNT=‘NT Authority\System’ /SQLSYSADMINACCOUNTS=’.\Administrator’ /AGTSVCACCOUNT=‘NT Authority\System’ /SECURITYMODE=SQL /SAPWD=‘Pa$w0rd’ /SQLTEMPDBDIR=‘C:\MSSQL\TempDB\’ /SQLUSERDBDIR=‘C:\MSSQL\Data\’ /SQLUSERDBLOGDIR=‘C:\MSSQL\Log\’
$env:Path += “;C:\Program Files\nodejs”;
ECHO Y | npm install -g @angular/cli;