Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/monitor/azure-mgmt-monitor/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
install_requires=[
'msrest>=0.6.21',
'azure-common~=1.1',
'azure-mgmt-core>=1.2.0,<2.0.0',
'azure-mgmt-core>=1.3.0,<2.0.0',
],
python_requires=">=3.6",
)
6 changes: 2 additions & 4 deletions sdk/monitor/azure-monitor-query/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

## 1.0.2 (Unreleased)

### Features Added

### Breaking Changes
- This version and all future versions will require Python 3.7+. Python 2.7 and 3.6 are no longer supported.

### Bugs Fixed

### Other Changes
- Fixed a bug where having a None value in datetime throws

## 1.0.1 (2021-11-09)

Expand Down
4 changes: 2 additions & 2 deletions sdk/monitor/azure-monitor-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ The Azure Monitor Query client library is used to execute read-only queries agai

## _Disclaimer_

_Azure SDK Python packages support for Python 2.7 is ending 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
_Azure SDK Python packages support for Python 2.7 has ended on 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_

## Getting started

### Prerequisites

- Python 2.7, or 3.6 or later
- Python 3.6 or later
- An [Azure subscription][azure_subscription]
- To query Logs, you need an [Azure Log Analytics workspace][azure_monitor_create_using_portal].
- To query Metrics, you need an Azure resource of any kind (Storage Account, Key Vault, Cosmos DB, etc.).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ def construct_iso8601(timespan=None):

def native_col_type(col_type, value):
if col_type == "datetime":
value = Deserializer.deserialize_iso(value)
try:
value = Deserializer.deserialize_iso(value)
except: # pylint: disable=bare-except
# if there is any exception in deserializing the iso,
# return the value to the user
pass
elif col_type in ("timespan", "guid"):
value = str(value)
return value
Expand Down
2 changes: 1 addition & 1 deletion sdk/monitor/azure-monitor-query/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
-e ../../core/azure-core
-e ../../identity/azure-identity
azure-mgmt-loganalytics
aiohttp>=3.0; python_version >= '3.5'
aiohttp>=3.0
4 changes: 2 additions & 2 deletions sdk/monitor/azure-monitor-query/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ The following code samples show common scenarios with the Azure Monitor Query cl

## _Disclaimer_

_Azure SDK Python packages support for Python 2.7 is ending 01 January 2022. For more information and questions, refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_.
_Azure SDK Python packages support for Python 2.7 has ended on 01 January 2022. For more information and questions, refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_.

## Prerequisites

- Python 2.7, or 3.6 or later
- Python 3.6 or later
- An [Azure subscription][azure_subscription]
- To query Logs, you need an [Azure Log Analytics workspace][azure_monitor_create_using_portal].
- To query Metrics, you need an Azure resource of any kind (Storage Account, Key Vault, Cosmos DB, etc.).
Expand Down
2 changes: 0 additions & 2 deletions sdk/monitor/azure-monitor-query/setup.cfg

This file was deleted.

10 changes: 3 additions & 7 deletions sdk/monitor/azure-monitor-query/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,15 @@
classifiers=[
"Development Status :: 5 - Production/Stable",
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'License :: OSI Approved :: MIT License',
],
python_requires=">=3.6",
zip_safe=False,
packages=find_packages(exclude=[
'tests',
Expand All @@ -84,8 +83,5 @@
install_requires=[
'msrest>=0.6.19',
'azure-core<2.0.0,>=1.12.0',
],
extras_require={
":python_version<'3.0'": ['azure-monitor-nspkg'],
}
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async def test_logs_query_batch_additional_workspaces():
async def test_logs_single_query_with_render():
credential = _credential()
client = LogsQueryClient(credential)
query = """AppRequests"""
query = """AppRequests | take 10"""

# returns LogsQueryResult
response = await client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_visualization=True)
Expand All @@ -171,7 +171,7 @@ async def test_logs_single_query_with_render():
async def test_logs_single_query_with_render_and_stats():
credential = _credential()
client = LogsQueryClient(credential)
query = """AppRequests"""
query = """AppRequests | take 10"""

# returns LogsQueryResult
response = await client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_visualization=True, include_statistics=True)
Expand All @@ -184,7 +184,7 @@ async def test_logs_single_query_with_render_and_stats():
async def test_logs_query_result_iterate_over_tables():
client = LogsQueryClient(_credential())

query = "AppRequests; AppRequests | take 5"
query = "AppRequests | take 10; AppRequests | take 5"

response = await client.query_workspace(
os.environ['LOG_WORKSPACE_ID'],
Expand Down
33 changes: 0 additions & 33 deletions sdk/monitor/azure-monitor-query/tests/conftest.py

This file was deleted.

16 changes: 12 additions & 4 deletions sdk/monitor/azure-monitor-query/tests/test_logs_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from azure.identity import ClientSecretCredential
from azure.core.exceptions import HttpResponseError
from azure.monitor.query import LogsQueryClient, LogsBatchQuery, LogsQueryError, LogsTable, LogsQueryResult, LogsTableRow, LogsQueryPartialResult
from azure.monitor.query._helpers import native_col_type

def _credential():
credential = ClientSecretCredential(
Expand Down Expand Up @@ -117,7 +118,7 @@ def test_logs_query_batch_default():
def test_logs_single_query_with_statistics():
credential = _credential()
client = LogsQueryClient(credential)
query = """AppRequests"""
query = """AppRequests | take 10"""

# returns LogsQueryResult
response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_statistics=True)
Expand All @@ -128,7 +129,7 @@ def test_logs_single_query_with_statistics():
def test_logs_single_query_with_render():
credential = _credential()
client = LogsQueryClient(credential)
query = """AppRequests"""
query = """AppRequests | take 10"""

# returns LogsQueryResult
response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_visualization=True)
Expand All @@ -139,7 +140,7 @@ def test_logs_single_query_with_render():
def test_logs_single_query_with_render_and_stats():
credential = _credential()
client = LogsQueryClient(credential)
query = """AppRequests"""
query = """AppRequests | take 10"""

# returns LogsQueryResult
response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None, include_visualization=True, include_statistics=True)
Expand Down Expand Up @@ -228,7 +229,7 @@ def test_logs_query_batch_additional_workspaces():
def test_logs_query_result_iterate_over_tables():
client = LogsQueryClient(_credential())

query = "AppRequests; AppRequests | take 5"
query = "AppRequests | take 10; AppRequests | take 5"

response = client.query_workspace(
os.environ['LOG_WORKSPACE_ID'],
Expand Down Expand Up @@ -265,3 +266,10 @@ def test_logs_query_result_row_type():

for row in table.rows:
assert row.__class__ == LogsTableRow

def test_native_col_type():
val = native_col_type('datetime', None)
assert val is None

val = native_col_type('datetime', '2020-10-10')
assert val is not None
1 change: 1 addition & 0 deletions shared_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,4 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0
#override azure-mgmt-appconfiguration azure-mgmt-core>=1.3.0,<2.0.0
#override azure-mgmt-dnsresolver msrest>=0.6.21
#override azure-mgmt-dnsresolver azure-mgmt-core>=1.3.0,<2.0.0
#override azure-mgmt-monitor azure-mgmt-core>=1.3.0,<2.0.0