Skip to content

Commit 89dabd8

Browse files
bug fix for Set-AzVmBootDisagnostic (#16011)
* bug fix * add changelog
1 parent 0617c49 commit 89dabd8

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
-->
2222
## Upcoming Release
23+
* Update Set-AzVmBootDiagnostic to default to managed storage account if not provided.
2324
* Update Compute .NET SDK package reference to version 49.1.0
2425
* Fixed a bug in `Get-AzVM` that caused incorrect power status output.
2526

src/Compute/Compute/VirtualMachine/Config/SetAzureVMBootDiagnosticsCommand.cs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class SetAzureVMBootDiagnosticsCommand : Microsoft.Azure.Commands.Resourc
5656
public SwitchParameter Disable { get; set; }
5757

5858
[Parameter(
59-
Mandatory = true,
6059
Position = 2,
6160
ParameterSetName = EnableParameterSet,
6261
ValueFromPipelineByPropertyName = true,
@@ -86,14 +85,7 @@ public override void ExecuteCmdlet()
8685

8786
if (this.Enable.IsPresent)
8887
{
89-
if (string.IsNullOrEmpty(this.StorageAccountName))
90-
{
91-
if (diagnosticsProfile.BootDiagnostics.StorageUri == null)
92-
{
93-
ThrowNoStorageAccount();
94-
}
95-
}
96-
else
88+
if (!string.IsNullOrEmpty(this.StorageAccountName))
9789
{
9890
var storageClient = AzureSession.Instance.ClientFactory.CreateArmClient<StorageManagementClient>(
9991
DefaultProfile.DefaultContext, AzureEnvironment.Endpoint.ResourceManager);

src/Compute/Compute/help/Set-AzVMBootDiagnostic.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Modifies boot diagnostics properties of a virtual machine.
1515

1616
### EnableBootDiagnostics
1717
```
18-
Set-AzVMBootDiagnostic [-VM] <PSVirtualMachine> [-Enable] [-ResourceGroupName] <String>
18+
Set-AzVMBootDiagnostic [-VM] <PSVirtualMachine> [-Enable] [[-ResourceGroupName] <String>]
1919
[[-StorageAccountName] <String>] [-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
2020
```
2121

@@ -34,7 +34,7 @@ The **Set-AzVMBootDiagnostic** cmdlet modifies boot diagnostics properties of a
3434
```
3535
PS C:\> $VM = Get-AzVM -ResourceGroupName "ResourceGroup11" -Name "ContosoVM07"
3636
PS C:\> Set-AzVMBootDiagnostic -VM $VM -Enable -ResourceGroupName "ResourceGroup11" -StorageAccountName "DiagnosticStorage"
37-
PS C:\> Update-AzVM -VM $VM
37+
PS C:\> Update-AzVM -VM $VM -ResourceGroupName "ResourceGroup11"
3838
```
3939

4040
The first command gets the virtual machine named ContosoVM07 by using **Get-AzVM**.
@@ -97,15 +97,15 @@ Type: System.String
9797
Parameter Sets: EnableBootDiagnostics
9898
Aliases:
9999

100-
Required: True
100+
Required: False
101101
Position: 2
102102
Default value: None
103103
Accept pipeline input: True (ByPropertyName)
104104
Accept wildcard characters: False
105105
```
106106
107107
### -StorageAccountName
108-
Specifies the name of the storage account in which to save boot diagnostics data.
108+
Specifies the name of the storage account in which to save boot diagnostics data. If not provided, it will look for a StorageUri in the BootDiagnostic Profile in the PSVirtualMachine object provided in the '-VM' parameter. If StorageUri is null, it will default to used a managed storage account.
109109
110110
```yaml
111111
Type: System.String

0 commit comments

Comments
 (0)