From a8f30df3ed142b416093a85afa4fa2aa27f7edf9 Mon Sep 17 00:00:00 2001 From: "silent.mo" <1916393131@qq.com> Date: Wed, 31 Jul 2024 11:04:27 +0800 Subject: [PATCH] fix Azure receiver not azure china #34315 **Description:** Adding azure china in azure monitor receiver. **Link to tracking Issue:** #34315 --- receiver/azuremonitorreceiver/config.go | 3 ++- receiver/azuremonitorreceiver/scraper.go | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/receiver/azuremonitorreceiver/config.go b/receiver/azuremonitorreceiver/config.go index 90f7d7ef6292..6e835003e781 100644 --- a/receiver/azuremonitorreceiver/config.go +++ b/receiver/azuremonitorreceiver/config.go @@ -16,6 +16,7 @@ import ( const ( azureCloud = "AzureCloud" azureGovernmentCloud = "AzureUSGovernment" + azureChinaCloud = "AzureChinaCloud" ) var ( @@ -292,7 +293,7 @@ func (c Config) Validate() (err error) { return fmt.Errorf("authentication %v is not supported. supported authentications include [%v,%v,%v,%v]", c.Authentication, servicePrincipal, workloadIdentity, managedIdentity, defaultCredentials) } - if c.Cloud != azureCloud && c.Cloud != azureGovernmentCloud { + if c.Cloud != azureCloud && c.Cloud != azureGovernmentCloud && c.Cloud != azureChinaCloud { err = multierr.Append(err, errInvalidCloud) } diff --git a/receiver/azuremonitorreceiver/scraper.go b/receiver/azuremonitorreceiver/scraper.go index 8e5440dae0cd..1e4449016647 100644 --- a/receiver/azuremonitorreceiver/scraper.go +++ b/receiver/azuremonitorreceiver/scraper.go @@ -126,6 +126,8 @@ func (s *azureScraper) getArmClientOptions() *arm.ClientOptions { switch s.cfg.Cloud { case azureGovernmentCloud: cloudToUse = cloud.AzureGovernment + case azureChinaCloud: + cloudToUse = cloud.AzureChina default: cloudToUse = cloud.AzurePublic }