-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[Azure.Monitor] Add sovereign support for Query and Ingestion #37819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b78da57
cb30d24
c43645e
ce69668
49e4bfa
1b97ca1
a0ef46c
8a982db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,9 @@ | |
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using Azure.Core.TestFramework; | ||
| using NUnit.Framework; | ||
|
|
||
| namespace Azure.Monitor.Query.Tests | ||
| { | ||
|
|
@@ -16,10 +18,35 @@ public class MonitorQueryTestEnvironment : TestEnvironment | |
| public string MetricsNamespace => GetRecordedVariable("METRICS_RESOURCE_NAMESPACE"); | ||
| public string MonitorIngestionEndpoint => GetOptionalVariable("METRICS_INGEST_SUFFIX") ?? "ods.opinsights.azure.com"; | ||
| public string MetricsIngestionEndpoint => GetOptionalVariable("METRICS_INGEST_SUFFIX") ?? "monitoring.azure.com"; | ||
| public Uri LogsEndpoint => new(GetRecordedVariable("LOGS_ENDPOINT")); | ||
| public Uri MetricsEndpoint => new(ResourceManagerUrl); | ||
| public string ResourceId => GetRecordedVariable("RESOURCE_ID"); | ||
| public string WorkspacePrimaryResourceId => GetRecordedVariable("WORKSPACE_PRIMARY_RESOURCE_ID"); | ||
| public string WorkspaceSecondaryResourceId => GetRecordedVariable("WORKSPACE_SECONDARY_RESOURCE_ID"); | ||
| public Uri LogsEndpoint => new(GetEndpoint()); | ||
|
|
||
| private Dictionary<string, string> regions = new Dictionary<string, string>() | ||
| { | ||
| { "AzureCloud", "https://api.loganalytics.io/v1" }, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it not possible to pull this down via the bicep file?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No I don't believe so. Other languages are pulling from the test environment as well
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the service doesn't expose these endpoints programmatically? Users have to look at docs?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about monitor in particular but a lot of services have this hard coded and expect people to discover this through documentation.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am curious about v1 in the end - Does the service have v2 endpoints too? Is this their versioning scheme?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes the service is in v1 right now and v2 I'm assuming will come out in the future. |
||
| { "AzureChinaCloud", "https://api.loganalytics.azure.cn/v1" }, | ||
| { "AzureUSGovernment", "https://api.loganalytics.us/v1" } | ||
| }; | ||
|
|
||
| private string ENV_MONITOR_ENVIRONMENT = "MONITOR_ENVIRONMENT"; | ||
| private string GetEndpoint() | ||
| { | ||
| // if mode is Playback use DefaultEndpoint | ||
| if (Mode == RecordedTestMode.Playback) | ||
| { | ||
| return GetRecordedVariable("LOGS_ENDPOINT"); | ||
| } | ||
| // else find endpoing of specific region from pipeline | ||
| string endpoint = ""; | ||
| TestContext.Progress.WriteLine("Current Region: " + Environment.GetEnvironmentVariable(ENV_MONITOR_ENVIRONMENT)); | ||
| if (regions.TryGetValue(Environment.GetEnvironmentVariable(ENV_MONITOR_ENVIRONMENT), out string region)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this environment variable get set?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you! |
||
| { | ||
| endpoint = region; | ||
| } | ||
| return endpoint; | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail during playback as we are no longer looking up the recorded variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can check if the mode is playback and set it to the default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, if it is playback it would need to check the recorded value in the session record, which is what GetRecordedVariable does.
It would probably be cleaner if we could move the GetEndpoint logic directly into the bicep file so that we are setting the LOGS_ENDPOINT env var based on the Azure Environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't want to go that route, then we would at least need to condition on whether we are in PlayBack mode and if so, call GetRecordedVariable rather than GetEndpoint.