diff --git a/azure-kusto-ingest/azure/kusto/ingest/_resource_manager.py b/azure-kusto-ingest/azure/kusto/ingest/_resource_manager.py index 50c769dd..66e529ba 100644 --- a/azure-kusto-ingest/azure/kusto/ingest/_resource_manager.py +++ b/azure-kusto-ingest/azure/kusto/ingest/_resource_manager.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from typing import List, Dict from urllib.parse import urlparse @@ -85,7 +85,8 @@ def __set_throttling_settings(self, num_of_attempts: int = 4, max_seconds_per_re def _refresh_ingest_client_resources(self): if ( not self._ingest_client_resources - or (self._ingest_client_resources_last_update + self._refresh_period) <= datetime.utcnow() + or (self._ingest_client_resources_last_update + self._refresh_period) + <= datetime.now(tz=timezone.utc) or not self._ingest_client_resources.is_applicable() ): self._ingest_client_resources = self._get_ingest_client_resources_from_service() @@ -119,10 +120,11 @@ def _refresh_authorization_context(self): if ( not self._authorization_context or self._authorization_context.isspace() - or (self._authorization_context_last_update + self._refresh_period) <= datetime.utcnow() + or (self._authorization_context_last_update + self._refresh_period) + <= datetime.now(tz=timezone.utc) ): self._authorization_context = self._get_authorization_context_from_service() - self._authorization_context_last_update = datetime.utcnow() + self._authorization_context_last_update = datetime.now(tz=timezone.utc) def _get_authorization_context_from_service(self): # trace all calls to get identity token diff --git a/azure-kusto-ingest/azure/kusto/ingest/ingestion_blob_info.py b/azure-kusto-ingest/azure/kusto/ingest/ingestion_blob_info.py index 29ce9a63..9496267c 100644 --- a/azure-kusto-ingest/azure/kusto/ingest/ingestion_blob_info.py +++ b/azure-kusto-ingest/azure/kusto/ingest/ingestion_blob_info.py @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License import json -from datetime import datetime +from datetime import datetime, timezone from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -28,7 +28,9 @@ def __init__( self.properties["IgnoreSizeLimit"] = False self.properties["ReportLevel"] = ingestion_properties.report_level.value self.properties["ReportMethod"] = ingestion_properties.report_method.value - self.properties["SourceMessageCreationTime"] = datetime.utcnow().isoformat() + self.properties["SourceMessageCreationTime"] = datetime.now( + tz=timezone.utc + ).isoformat() self.properties["Id"] = str(blob_descriptor.source_id) self.properties["ApplicationForTracing"] = application_for_tracing self.properties["ClientVersionForTracing"] = client_version_for_tracing