Skip to content

Commit 7bfe8af

Browse files
support withBootDiagnosticsOnManagedStorageAccount (#1372)
1 parent 2f5b5aa commit 7bfe8af

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/VirtualMachine.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,14 @@ interface WithPlan {
16501650
* The stage of the virtual machine definition allowing to enable boot diagnostics.
16511651
*/
16521652
interface WithBootDiagnostics {
1653+
/**
1654+
* Specifies that boot diagnostics needs to be enabled in the virtual machine.
1655+
* Managed storage account is used.
1656+
*
1657+
* @return the next stage of the definition
1658+
*/
1659+
WithCreate withBootDiagnosticsOnManagedStorageAccount();
1660+
16531661
/**
16541662
* Specifies that boot diagnostics needs to be enabled in the virtual machine.
16551663
*
@@ -2221,6 +2229,14 @@ interface WithExtension {
22212229
* The stage of the virtual machine definition allowing to enable boot diagnostics.
22222230
*/
22232231
interface WithBootDiagnostics {
2232+
/**
2233+
* Specifies that boot diagnostics needs to be enabled in the virtual machine.
2234+
* Managed storage account is used.
2235+
*
2236+
* @return the next stage of the update
2237+
*/
2238+
Update withBootDiagnosticsOnManagedStorageAccount();
2239+
22242240
/**
22252241
* Specifies that boot diagnostics needs to be enabled in the virtual machine.
22262242
*

azure-mgmt-compute/src/main/java/com/microsoft/azure/management/compute/implementation/VirtualMachineImpl.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,9 +1391,15 @@ public VirtualMachineImpl withUnmanagedDisks() {
13911391
return this;
13921392
}
13931393

1394+
@Override
1395+
public VirtualMachineImpl withBootDiagnosticsOnManagedStorageAccount() {
1396+
this.bootDiagnosticsHandler.withBootDiagnostics(true);
1397+
return this;
1398+
}
1399+
13941400
@Override
13951401
public VirtualMachineImpl withBootDiagnostics() {
1396-
this.bootDiagnosticsHandler.withBootDiagnostics();
1402+
this.bootDiagnosticsHandler.withBootDiagnostics(false);
13971403
return this;
13981404
}
13991405

@@ -2733,6 +2739,7 @@ private StorageAccountTypes getDefaultStorageAccountType() {
27332739
private class BootDiagnosticsHandler {
27342740
private final VirtualMachineImpl vmImpl;
27352741
private String creatableDiagnosticsStorageAccountKey;
2742+
private boolean useManagedStorageAccount = false;
27362743

27372744
BootDiagnosticsHandler(VirtualMachineImpl vmImpl) {
27382745
this.vmImpl = vmImpl;
@@ -2756,10 +2763,11 @@ public String bootDiagnosticsStorageUri() {
27562763
return null;
27572764
}
27582765

2759-
BootDiagnosticsHandler withBootDiagnostics() {
2766+
BootDiagnosticsHandler withBootDiagnostics(boolean useManagedStorageAccount) {
27602767
// Diagnostics storage uri will be set later by this.handleDiagnosticsSettings(..)
27612768
//
27622769
this.enableDisable(true);
2770+
this.useManagedStorageAccount = useManagedStorageAccount;
27632771
return this;
27642772
}
27652773

@@ -2773,6 +2781,7 @@ BootDiagnosticsHandler withBootDiagnostics(Creatable<StorageAccount> creatable)
27732781

27742782
BootDiagnosticsHandler withBootDiagnostics(String storageAccountBlobEndpointUri) {
27752783
this.enableDisable(true);
2784+
this.useManagedStorageAccount = false;
27762785
this.vmInner()
27772786
.diagnosticsProfile()
27782787
.bootDiagnostics()
@@ -2786,10 +2795,14 @@ BootDiagnosticsHandler withBootDiagnostics(StorageAccount storageAccount) {
27862795

27872796
BootDiagnosticsHandler withoutBootDiagnostics() {
27882797
this.enableDisable(false);
2798+
this.useManagedStorageAccount = false;
27892799
return this;
27902800
}
27912801

27922802
void prepare() {
2803+
if (useManagedStorageAccount) {
2804+
return;
2805+
}
27932806
DiagnosticsProfile diagnosticsProfile = this.vmInner().diagnosticsProfile();
27942807
if (diagnosticsProfile == null
27952808
|| diagnosticsProfile.bootDiagnostics() == null
@@ -2822,6 +2835,9 @@ void prepare() {
28222835
}
28232836

28242837
void handleDiagnosticsSettings() {
2838+
if (useManagedStorageAccount) {
2839+
return;
2840+
}
28252841
DiagnosticsProfile diagnosticsProfile = this.vmInner().diagnosticsProfile();
28262842
if (diagnosticsProfile == null
28272843
|| diagnosticsProfile.bootDiagnostics() == null

0 commit comments

Comments
 (0)