diff --git a/src/spring/HISTORY.md b/src/spring/HISTORY.md index 30ac53c6288..1b2785a326d 100644 --- a/src/spring/HISTORY.md +++ b/src/spring/HISTORY.md @@ -1,5 +1,9 @@ Release History =============== +1.28.2 +--- +* Remove DATA_COSMOS_TABLE and DATA_STORAGE references + 1.28.1 --- * Fix clean up config file patterns of Application Configuration Service. diff --git a/src/spring/azext_spring/_deployment_deployable_factory.py b/src/spring/azext_spring/_deployment_deployable_factory.py index 3dd4a39bbeb..1c173cc6f5e 100644 --- a/src/spring/azext_spring/_deployment_deployable_factory.py +++ b/src/spring/azext_spring/_deployment_deployable_factory.py @@ -110,7 +110,7 @@ def get_logs_loop(): sleep(10) logger.warning("Trying to fetch build logs") - stream_logs(client.deployments, resource_group, service, + stream_logs(self.cmd, client.deployments, resource_group, service, app, deployment, logger_level_func=print) old_log_url = get_log_url() timer = Timer(3, get_logs_loop) diff --git a/src/spring/azext_spring/_deployment_uploadable_factory.py b/src/spring/azext_spring/_deployment_uploadable_factory.py index 88a72e1f728..97d5ed9f92f 100644 --- a/src/spring/azext_spring/_deployment_uploadable_factory.py +++ b/src/spring/azext_spring/_deployment_uploadable_factory.py @@ -30,6 +30,7 @@ def __init__(self, upload_url, cli_ctx): self.relative_name = relative_name self.sas_token = sas_token self.cli_ctx = cli_ctx + self.upload_url = upload_url def upload_and_build(self, artifact_path, **_): if not artifact_path: @@ -41,9 +42,10 @@ def upload_and_build(self, artifact_path, **_): raise InvalidArgumentValueError('Unexpected artifact file type, must be one of .zip, .tar.gz, .tar, .jar, .war.') def _upload(self, artifact_path): - FileService = get_sdk(self.cli_ctx, ResourceType.DATA_STORAGE, 'file#FileService') - file_service = FileService(self.account_name, sas_token=self.sas_token, endpoint_suffix=self.endpoint_suffix) - file_service.create_file_from_path(self.share_name, None, self.relative_name, artifact_path) + ShareFileClient = get_sdk(self.cli_ctx, ResourceType.DATA_STORAGE_FILESHARE, '_file_client#ShareFileClient') + file_client = ShareFileClient.from_file_url(self.upload_url) + with open(artifact_path, 'rb') as stream: + file_client.upload_file(data=stream) class FolderUpload(FileUpload): diff --git a/src/spring/azext_spring/_stream_utils.py b/src/spring/azext_spring/_stream_utils.py index 4f5b959ef55..0315ef56754 100644 --- a/src/spring/azext_spring/_stream_utils.py +++ b/src/spring/azext_spring/_stream_utils.py @@ -12,9 +12,8 @@ from knack.util import CLIError from knack.log import get_logger from azure.core.exceptions import HttpResponseError -from azure.multiapi.storage.v2018_11_09.blob import AppendBlobService +from azure.cli.core.profiles import ResourceType, get_sdk from azure.common import AzureHttpError -from ._utils import get_blob_info logger = get_logger(__name__) @@ -22,7 +21,8 @@ DEFAULT_LOG_TIMEOUT_IN_SEC = 60 * 30 # 30 minutes -def stream_logs(client, +def stream_logs(cmd, + client, resource_group, service, app, @@ -47,18 +47,13 @@ def stream_logs(client, logger.warning("%s Empty SAS URL.", error_msg) raise CLIError(error_msg) - account_name, endpoint_suffix, container_name, blob_name, sas_token = get_blob_info( - log_file_sas) + BlobClient = get_sdk(cmd.cli_ctx, ResourceType.DATA_STORAGE_BLOB, '_blob_client#BlobClient') + blob_client = BlobClient.from_blob_url(log_file_sas) _stream_logs(no_format, DEFAULT_CHUNK_SIZE, DEFAULT_LOG_TIMEOUT_IN_SEC, - AppendBlobService( - account_name=account_name, - sas_token=sas_token, - endpoint_suffix=endpoint_suffix), - container_name, - blob_name, + blob_client, raise_error_on_failure, logger_level_func) @@ -67,8 +62,6 @@ def _stream_logs(no_format, # pylint: disable=too-many-locals, too-many-stateme byte_size, timeout_in_seconds, blob_service, - container_name, - blob_name, raise_error_on_failure, logger_level_func): @@ -78,7 +71,6 @@ def _stream_logs(no_format, # pylint: disable=too-many-locals, too-many-stateme stream = BytesIO() metadata = {} start = 0 - end = byte_size - 1 available = 0 sleep_time = 1 max_sleep_time = 15 @@ -97,11 +89,9 @@ def safe_get_blob_properties(): ''' nonlocal blob_exists if not blob_exists: - blob_exists = blob_service.exists( - container_name=container_name, blob_name=blob_name) + blob_exists = blob_service.exists() if blob_exists: - return blob_service.get_blob_properties( - container_name=container_name, blob_name=blob_name) + return blob_service.get_blob_properties() return None # Try to get the initial properties so there's no waiting. @@ -110,7 +100,7 @@ def safe_get_blob_properties(): props = safe_get_blob_properties() if props: metadata = props.metadata - available = props.properties.content_length + available = props.size except (AttributeError, AzureHttpError): pass @@ -123,18 +113,13 @@ def safe_get_blob_properties(): try: old_byte_size = len(stream.getvalue()) - blob_service.get_blob_to_stream( - container_name=container_name, - blob_name=blob_name, - start_range=start, - end_range=end, - stream=stream) + downloader = blob_service.download_blob(offset=start, length=byte_size, max_concurrency=1) + downloader.readinto(stream) curr_bytes = stream.getvalue() new_byte_size = len(curr_bytes) amount_read = new_byte_size - old_byte_size start += amount_read - end = start + byte_size - 1 # Only scan what's newly read. If nothing is read, default to 0. min_scan_range = max(new_byte_size - amount_read - 1, 0) @@ -165,7 +150,7 @@ def safe_get_blob_properties(): props = safe_get_blob_properties() if props: metadata = props.metadata - available = props.properties.content_length + available = props.size except AzureHttpError as ae: if ae.status_code != 404: raise CLIError(ae) diff --git a/src/spring/azext_spring/custom.py b/src/spring/azext_spring/custom.py index 55b4eb32cd6..9be7e2094dd 100644 --- a/src/spring/azext_spring/custom.py +++ b/src/spring/azext_spring/custom.py @@ -528,7 +528,7 @@ def parse_auth_flags(auth_list): def app_get_build_log(cmd, client, resource_group, service, name, deployment=None): if deployment.properties.source.type != "Source": raise CLIError("{} deployment has no build logs.".format(deployment.properties.source.type)) - return stream_logs(client.deployments, resource_group, service, name, deployment.name) + return stream_logs(cmd, client.deployments, resource_group, service, name, deployment.name) def app_tail_log(cmd, client, resource_group, service, name, diff --git a/src/spring/setup.py b/src/spring/setup.py index 455a6f10248..f384903808a 100644 --- a/src/spring/setup.py +++ b/src/spring/setup.py @@ -16,7 +16,7 @@ # TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '1.28.1' +VERSION = '1.28.2' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers