From ccf329aaa85dfaa1319f185ef5cf88043fcb39fc Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Thu, 21 Oct 2021 21:29:16 -0500 Subject: [PATCH 1/3] Update Monitor Query library samples --- .../async_samples/sample_log_query_async.py | 14 +++++--------- .../sample_metric_definitions_async.py | 8 ++------ .../sample_metric_namespaces_async.py | 10 +++------- .../async_samples/sample_metrics_query_async.py | 13 +++++-------- .../samples/sample_batch_query.py | 16 +++++----------- .../sample_log_query_multiple_workspaces.py | 11 +++-------- .../samples/sample_logs_query_key_value_form.py | 11 +++-------- .../samples/sample_logs_single_query.py | 11 +++-------- .../sample_logs_single_query_partial_result.py | 11 +++-------- .../samples/sample_metric_definitions.py | 8 ++------ .../samples/sample_metric_namespaces.py | 8 ++------ .../samples/sample_metrics_query.py | 11 ++++------- .../samples/sample_server_timeout.py | 13 ++++--------- .../sample_single_log_query_without_pandas.py | 8 +------- 14 files changed, 45 insertions(+), 108 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py index a1697b8494eb..dd1b083328ef 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py @@ -3,19 +3,15 @@ """ FILE: sample_logs_single_query_async.py DESCRIPTION: - This sample demonstrates authenticating the LogsQueryClient and querying a single query. + This sample demonstrates authenticating the LogsQueryClient and executing a single + Kusto query. USAGE: python sample_logs_single_query_async.py Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. - -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import asyncio import os @@ -34,7 +30,7 @@ async def logs_query(): query= """AppRequests | take 5""" try: - response = await client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = await client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: error = response.partial_error data = response.partial_data diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py index dc2aeab0f6dc..d0de0177be83 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py @@ -7,13 +7,9 @@ USAGE: python sample_metric_definitions_async.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, an eventgrid account resource URI is taken. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + In this example, an Event Grid account resource URI is taken. """ import os import asyncio diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py index 7418414eb0df..3b0c7367af96 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py @@ -7,13 +7,9 @@ USAGE: python sample_metric_namespaces_async.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, a storage account resource URI is taken. - - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. + + In this example, a Storage account resource URI is taken. """ import os import asyncio diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py index 78cad14ff6b9..4e8c85b383e4 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py @@ -3,18 +3,15 @@ """ FILE: sample_metrics_query_async.py DESCRIPTION: - This sample demonstrates authenticating the LogsQueryClient and querying a single query - on multiple workspaces using the additional_workspaces param. + This sample demonstrates authenticating the MetricsQueryClient and retrieving the "Ingress" + metric along with the "Average" aggregation type. The query will execute over a timespan + of 2 hours with a granularity of 15 minutes. USAGE: python sample_metrics_query_async.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, a storage account resource URI is taken. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + In this example, a Storage account resource URI is taken. """ import os import asyncio diff --git a/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py b/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py index 95d6f9ac9efe..92bfcc4ac551 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py @@ -9,13 +9,8 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. - -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ from datetime import datetime, timedelta, timezone @@ -24,7 +19,6 @@ from azure.monitor.query import LogsQueryClient, LogsBatchQuery, LogsQueryStatus from azure.identity import DefaultAzureCredential - credential = DefaultAzureCredential() client = LogsQueryClient(credential) @@ -34,18 +28,18 @@ LogsBatchQuery( query="AzureActivity | summarize count()", timespan=timedelta(hours=1), - workspace_id= os.environ['LOG_WORKSPACE_ID'] + workspace_id= os.environ['LOGS_WORKSPACE_ID'] ), LogsBatchQuery( query= """bad query""", timespan=timedelta(days=1), - workspace_id= os.environ['LOG_WORKSPACE_ID'] + workspace_id= os.environ['LOGS_WORKSPACE_ID'] ), LogsBatchQuery( query= """let Weight = 92233720368547758; range x from 1 to 3 step 1 | summarize percentilesw(x, Weight * 100, 50)""", - workspace_id= os.environ['LOG_WORKSPACE_ID'], + workspace_id= os.environ['LOGS_WORKSPACE_ID'], timespan=(datetime(2021, 6, 2, tzinfo=timezone.utc), datetime(2021, 6, 5, tzinfo=timezone.utc)), # (start, end) include_statistics=True ), diff --git a/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py b/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py index 2a4b86674561..bced4bd1be61 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py @@ -11,13 +11,8 @@ 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. 2) SECONDARY_WORKSPACE_ID - An additional workspace. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. - -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -34,7 +29,7 @@ try: response = client.query_workspace( - os.environ['LOG_WORKSPACE_ID'], + os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1), additional_workspaces=[os.environ['SECONDARY_WORKSPACE_ID']] diff --git a/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py b/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py index 22ec67a6a096..d1819a5cfa6e 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py @@ -10,13 +10,8 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. - -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -33,7 +28,7 @@ query= """AppRequests | take 5""" try: - response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: error = response.partial_error data = response.partial_data diff --git a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py index 0e163ea06f78..c4f789a13173 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py @@ -9,13 +9,8 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. - -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -34,7 +29,7 @@ query= """AppRequests | take 5""" try: - response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: error = response.partial_error data = response.partial_data diff --git a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py index 6c0d41a575a7..8bd57af8a317 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py @@ -10,13 +10,8 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. - -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -37,7 +32,7 @@ # this block of code is exactly the same whether the expected result is a success, a failure or a # partial success try: - response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: # handle error here error = response.partial_error diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py index 8ab1778a2c85..21e0ebd5aa24 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py @@ -8,12 +8,8 @@ python sample_metric_definitions.py Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, an eventgrid account resource URI is taken. - - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + + In this example, an Event Grid account resource URI is taken. """ import os from azure.monitor.query import MetricsQueryClient diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py index ccc51bbf0fb6..05434221152b 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py @@ -8,12 +8,8 @@ python sample_metric_namespaces.py Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, a storage account resource URI is taken. - - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + + In this example, a Storage account resource URI is taken. """ import os from azure.monitor.query import MetricsQueryClient diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py b/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py index 0c1844b59792..cf605abf9396 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py @@ -3,18 +3,15 @@ """ FILE: sample_metrics_query.py DESCRIPTION: - This sample demonstrates authenticating the LogsQueryClient and querying a single query - on multiple workspaces using the additional_workspaces param. + This sample demonstrates authenticating the MetricsQueryClient and retrieving the "Ingress" + metric along with the "Average" aggregation type. The query will execute over a timespan + of 2 hours with a granularity of 5 minutes. USAGE: python sample_metrics_query.py Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. - In this example, a storage account resource URI is taken. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. + In this example, a Storage account resource URI is taken. """ import os from datetime import timedelta diff --git a/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py b/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py index 812091440925..0414ceceb9d9 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py @@ -3,19 +3,14 @@ """ FILE: sample_server_timeout.py DESCRIPTION: - This sample demostrates how to update a server timeout for a long running query. + This sample demonstrates how to update a server timeout for a long running query. USAGE: python sample_server_timeout.py Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. - -**Note** - Although this example uses pandas to prin the response, it is totally optional and is -not a required package for querying. Alternatively, native python can be used as well. +**Note** - Although this example uses pandas to print the response, it's optional and +isn't a required package for querying. Alternatively, native Python can be used as well. """ import os import pandas as pd @@ -32,7 +27,7 @@ try: response = client.query_workspace( - os.environ['LOG_WORKSPACE_ID'], + os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1), server_timeout=3 diff --git a/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py b/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py index 5f8a9f09fafd..fb13e48faa9e 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py @@ -9,11 +9,6 @@ python sample_single_log_query_without_pandas.py Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. - - In order to use the DefaultAzureCredential, the following environment variables must be set: - 1) AZURE_CLIENT_ID - The client ID of a user-assigned managed identity. - 2) AZURE_TENANT_ID - Tenant ID to use when authenticating a user. - 3) AZURE_CLIENT_ID - The client secret to be used for authentication. """ import os from datetime import timedelta @@ -27,9 +22,8 @@ query= """AppRequests | take 5""" - try: - response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1)) + response = client.query_workspace(os.environ['LOGS_WORKSPACE_ID'], query, timespan=timedelta(days=1)) if response.status == LogsQueryStatus.PARTIAL: # handle error here error = response.partial_error From 0ed02bfdb574fc6fa0233aefb1706abd6e7d7c88 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Thu, 21 Oct 2021 21:31:22 -0500 Subject: [PATCH 2/3] Update casing of uri --- .../azure-monitor-query/samples/sample_metric_definitions.py | 2 +- .../azure-monitor-query/samples/sample_metric_namespaces.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py index 21e0ebd5aa24..c28133268dd8 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py @@ -7,7 +7,7 @@ USAGE: python sample_metric_definitions.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. In this example, an Event Grid account resource URI is taken. """ diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py index 05434221152b..83212515fea8 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py @@ -7,7 +7,7 @@ USAGE: python sample_metric_namespaces.py Set the environment variables with your own values before running the sample: - 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. + 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. In this example, a Storage account resource URI is taken. """ From 0d482796b257ff7cc1cff2d1712a378190b78c11 Mon Sep 17 00:00:00 2001 From: Scott Addie Date: Mon, 25 Oct 2021 18:37:46 -0500 Subject: [PATCH 3/3] Link to DefaultAzureCredential docs --- .../samples/async_samples/sample_log_query_async.py | 3 +++ .../samples/async_samples/sample_metric_definitions_async.py | 3 +++ .../samples/async_samples/sample_metric_namespaces_async.py | 3 +++ .../samples/async_samples/sample_metrics_query_async.py | 3 +++ sdk/monitor/azure-monitor-query/samples/sample_batch_query.py | 3 +++ .../samples/sample_log_query_multiple_workspaces.py | 3 +++ .../samples/sample_logs_query_key_value_form.py | 3 +++ .../azure-monitor-query/samples/sample_logs_single_query.py | 3 +++ .../samples/sample_logs_single_query_partial_result.py | 3 +++ .../azure-monitor-query/samples/sample_metric_definitions.py | 3 +++ .../azure-monitor-query/samples/sample_metric_namespaces.py | 3 +++ .../azure-monitor-query/samples/sample_metrics_query.py | 3 +++ .../azure-monitor-query/samples/sample_server_timeout.py | 3 +++ .../samples/sample_single_log_query_without_pandas.py | 3 +++ 14 files changed, 42 insertions(+) diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py index dd1b083328ef..336b6f8d3861 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py @@ -10,6 +10,9 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + **Note** - Although this example uses pandas to print the response, it's optional and isn't a required package for querying. Alternatively, native Python can be used as well. """ diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py index d0de0177be83..1b1ebd8068c7 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py @@ -9,6 +9,9 @@ Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + In this example, an Event Grid account resource URI is taken. """ import os diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py index 3b0c7367af96..cb6379804589 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py @@ -9,6 +9,9 @@ Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + In this example, a Storage account resource URI is taken. """ import os diff --git a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py index 4e8c85b383e4..3ecd89d0a143 100644 --- a/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py +++ b/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py @@ -11,6 +11,9 @@ Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + In this example, a Storage account resource URI is taken. """ import os diff --git a/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py b/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py index 92bfcc4ac551..2963914143e7 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py @@ -9,6 +9,9 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The The first (primary) workspace ID. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + **Note** - Although this example uses pandas to print the response, it's optional and isn't a required package for querying. Alternatively, native Python can be used as well. """ diff --git a/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py b/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py index bced4bd1be61..7be747030e92 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py @@ -11,6 +11,9 @@ 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. 2) SECONDARY_WORKSPACE_ID - An additional workspace. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + **Note** - Although this example uses pandas to print the response, it's optional and isn't a required package for querying. Alternatively, native Python can be used as well. """ diff --git a/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py b/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py index d1819a5cfa6e..d8877d521388 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py @@ -10,6 +10,9 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + **Note** - Although this example uses pandas to print the response, it's optional and isn't a required package for querying. Alternatively, native Python can be used as well. """ diff --git a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py index c4f789a13173..7b62b2d2c361 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py @@ -9,6 +9,9 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + **Note** - Although this example uses pandas to print the response, it's optional and isn't a required package for querying. Alternatively, native Python can be used as well. """ diff --git a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py index 8bd57af8a317..9830c426c961 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query_partial_result.py @@ -10,6 +10,9 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + **Note** - Although this example uses pandas to print the response, it's optional and isn't a required package for querying. Alternatively, native Python can be used as well. """ diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py index c28133268dd8..74b7ef45c88e 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py @@ -9,6 +9,9 @@ Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + In this example, an Event Grid account resource URI is taken. """ import os diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py index 83212515fea8..2a03b6ad421d 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py @@ -9,6 +9,9 @@ Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource URI of the resource for which the metrics are being queried. + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + In this example, a Storage account resource URI is taken. """ import os diff --git a/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py b/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py index cf605abf9396..434fe860b933 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py @@ -11,6 +11,9 @@ Set the environment variables with your own values before running the sample: 1) METRICS_RESOURCE_URI - The resource uri of the resource for which the metrics are being queried. + This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. + For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + In this example, a Storage account resource URI is taken. """ import os diff --git a/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py b/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py index 0414ceceb9d9..354dbfc7a60d 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py @@ -9,6 +9,9 @@ Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. + **Note** - Although this example uses pandas to print the response, it's optional and isn't a required package for querying. Alternatively, native Python can be used as well. """ diff --git a/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py b/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py index fb13e48faa9e..a6aefb3aa6cb 100644 --- a/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py +++ b/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py @@ -9,6 +9,9 @@ python sample_single_log_query_without_pandas.py Set the environment variables with your own values before running the sample: 1) LOGS_WORKSPACE_ID - The first (primary) workspace ID. + +This example uses DefaultAzureCredential, which requests a token from Azure Active Directory. +For more information on DefaultAzureCredential, see https://docs.microsoft.com/python/api/overview/azure/identity-readme?view=azure-python#defaultazurecredential. """ import os from datetime import timedelta