diff --git a/public/app/plugins/datasource/azuremonitor/components/ConfigEditor/MonitorConfig.tsx b/public/app/plugins/datasource/azuremonitor/components/ConfigEditor/MonitorConfig.tsx index ff869479f9c..8a2dd691284 100644 --- a/public/app/plugins/datasource/azuremonitor/components/ConfigEditor/MonitorConfig.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/ConfigEditor/MonitorConfig.tsx @@ -1,4 +1,5 @@ import React, { useMemo, useState } from 'react'; +import { useEffectOnce } from 'react-use'; import { SelectableValue } from '@grafana/data'; import { config } from '@grafana/runtime'; @@ -48,6 +49,13 @@ export const MonitorConfig = (props: Props) => { const onSubscriptionChange = (subscriptionId?: string) => updateOptions((options) => ({ ...options, jsonData: { ...options.jsonData, subscriptionId } })); + // The auth type needs to be set on the first load of the data source + useEffectOnce(() => { + if (!options.jsonData.authType) { + onCredentialsChange(credentials); + } + }); + return ( <> { onChange(updateCredentials(dsSettings, config, credentials)); }; + // The auth type needs to be set on the first load of the data source + useEffectOnce(() => { + if (!dsSettings.jsonData.authType) { + onCredentialsChange(credentials); + } + }); + return ( { const labelWidth = prometheusConfigOverhaulAuth ? 24 : 26; + // The auth type needs to be set on the first load of the data source + useEffectOnce(() => { + if (!dataSourceConfig.jsonData.authType) { + onCredentialsChange(credentials); + } + }); + return ( <>
Azure authentication