Is it possible to install application while creating Azure VM from PowerShell?

Viewed 115

I am trying to create a new Azure VM from PowerShell.

I am currently using the below script to create VM:

$location = "EastUS"

$rgName = "TestRG"

$credential = Get-Credential

New-AzResourceGroup -Name $rgName -Location $location

New-AzVm `
    -ResourceGroupName $rgName `
    -Name "TestVM" `
    -Location $location `
    -VirtualNetworkName "TestVnet" `
    -SubnetName "TestSubnet" `
    -SecurityGroupName "TestNsg" `
    -PublicIpAddressName "TestPip" `
    -OpenPorts 80,3389 `
    -Credential $credential 

Can anyone achieve installing applications from PowerShell into Azure VM while creating it? If it's possible, how to do that? Can anyone assist??

Thanks in Advance.

1 Answers

You can not install apllication or add extension to the VM while creating the VM . Once VM will be provisioned then only can only install the application or the add the extension.

You can refer this Micorosoft Document to install the Custom Script Extension Using Set-AzVMExtension.

Related