Azure / Azure/azure-powershell
New-AzVM installs BGInfo extension automatically
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
When creating a new VM with 'New-AzVM' it will also install the BGInfo extension automatically
This will only happen if the '-VM' parameter is used to pass a virtual machine object. Even though BGInfo was not specified in the virtual machine object
```New-AzVM -ResourceGroupName $rgname -Location $loc -VM $vmconfig```
However, if you don't use the '-VM' parameter, then instead New-AzVM chooses default parameters and BGInfo is NOT installed
```New-AzVM -ResourceGroupName $rgname -Location $loc' -Name VMname```
You can see it here in New-AzVM source -
[https://github.com/Azure/azure-powershell/blob/452b2d747938bf63361214f840baa35a114f2c95/src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs#L1195](https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzure%2Fazure-powershell%2Fblob%2F452b2d747938bf63361214f840baa35a114f2c95%2Fsrc%2FCompute%2FCompute%2FVirtualMachine%2FOperation%2FNewAzureVMCommand.cs%23L1195&data=05%7C02%7CKevin.Gregoire%40microsoft.com%7C26a0f887faab4c2e187208dca12a7509%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638562450938338202%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=qYOg5f%2F2zuq0gDwJUDIXOyMaCaYsTdqarrwm1qWn5qo%3D&reserved=0)
The workaround is to use -DisableBginfoExtension, but that shouldn't be necessary since -VM isn't supposed to install BGInfo
Can we please change this so BGInfo does not automatically install?
### Issue script & Debug output
```PowerShell
Debug info was too long so it won't let me submit as it surpasses the character limit. If you need the debug logs please reach out to me internally
```
### Environment data
```PowerShell
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.13.2 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 7.1.0 Az.Compute {Add-AzImageDataDisk, Add-AzVhd, Add-AzVMAdditionalUnattendContent, Ad…
Script 7.1.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Add-AzApplicationG…
Script 6.12.1 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, …
```
### Error output
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.