diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/VmMetadataApiHandler.cs b/Microsoft.Azure.Cosmos/src/Telemetry/VmMetadataApiHandler.cs index 7a6c5e224e..c88bc1c510 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/VmMetadataApiHandler.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/VmMetadataApiHandler.cs @@ -39,15 +39,13 @@ internal static class VmMetadataApiHandler /// Check for environment variable COSMOS_DISABLE_VM_METADATA_ACCESS to decide if VM metadata call should be made or not. /// If environment variable is set to true, then VM metadata call will not be made. /// If environment variable is set to false, then VM metadata call will be made. - /// If environment variable is not set, then set the value according to the debugger which means - /// In Debug mode, it is will be true and VM metadata call will be disabled. - /// In Release mode, it is will be false and VM metadata call will be enabled. + /// If environment variable is not set, then VM metadata call will be made. /// . /// internal static void TryInitialize(CosmosHttpClient httpClient) { bool isVMMetadataAccessDisabled = - ConfigurationManager.GetEnvironmentVariable("COSMOS_DISABLE_VM_METADATA_ACCESS", System.Diagnostics.Debugger.IsAttached); + ConfigurationManager.GetEnvironmentVariable("COSMOS_DISABLE_VM_METADATA_ACCESS", false); if (isVMMetadataAccessDisabled) { return; diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/VmMetadataApiHandlerTest.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/VmMetadataApiHandlerTest.cs index 9ff7dc2472..2145815887 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/VmMetadataApiHandlerTest.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/VmMetadataApiHandlerTest.cs @@ -40,9 +40,13 @@ public void Initialize() [TestMethod] [DataRow("true", DisplayName = "When COSMOS_DISABLE_VM_METADATA_ACCESS is set as true, VM ID should not be fetched")] [DataRow("false", DisplayName = "When COSMOS_DISABLE_VM_METADATA_ACCESS is set as false, VM ID should be fetched")] + [DataRow(null, DisplayName = "When COSMOS_DISABLE_VM_METADATA_ACCESS is NOT set, VM ID should be fetched")] public async Task GetVmIdAsMachineIdTest(string isVmMetadataAccessDisabled) { - Environment.SetEnvironmentVariable("COSMOS_DISABLE_VM_METADATA_ACCESS", isVmMetadataAccessDisabled); + if (isVmMetadataAccessDisabled != null) + { + Environment.SetEnvironmentVariable("COSMOS_DISABLE_VM_METADATA_ACCESS", isVmMetadataAccessDisabled); + } try {