diff --git a/azure/converters/diagnostics.go b/azure/converters/diagnostics.go index bccb5d83b9f..c28c144847c 100644 --- a/azure/converters/diagnostics.go +++ b/azure/converters/diagnostics.go @@ -39,11 +39,13 @@ func GetDiagnosticsProfile(diagnostics *infrav1.Diagnostics) *armcompute.Diagnos }, } case infrav1.UserManagedDiagnosticsStorage: - return &armcompute.DiagnosticsProfile{ - BootDiagnostics: &armcompute.BootDiagnostics{ - Enabled: ptr.To(true), - StorageURI: &diagnostics.Boot.UserManaged.StorageAccountURI, - }, + if diagnostics.Boot.UserManaged != nil { + return &armcompute.DiagnosticsProfile{ + BootDiagnostics: &armcompute.BootDiagnostics{ + Enabled: ptr.To(true), + StorageURI: &diagnostics.Boot.UserManaged.StorageAccountURI, + }, + } } } } diff --git a/azure/converters/diagnostics_test.go b/azure/converters/diagnostics_test.go index 07741da659c..4af80a9da33 100644 --- a/azure/converters/diagnostics_test.go +++ b/azure/converters/diagnostics_test.go @@ -81,6 +81,16 @@ func TestGetDiagnosticsProfile(t *testing.T) { }, want: nil, }, + { + name: "nil diagnostics boot user managed", + diagnostics: &infrav1.Diagnostics{ + Boot: &infrav1.BootDiagnostics{ + StorageAccountType: infrav1.UserManagedDiagnosticsStorage, + UserManaged: nil, + }, + }, + want: nil, + }, } for _, tt := range tests { tt := tt