Skip to content

Commit 23d1487

Browse files
committed
Remove DATA_COSMOS_TABLE and DATA_STORAGE references from spring, no able to test as deprecated
1 parent 66b2c60 commit 23d1487

File tree

6 files changed

+24
-33
lines changed

6 files changed

+24
-33
lines changed

src/spring/HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Release History
22
===============
3+
1.28.2
4+
---
5+
* Remove DATA_COSMOS_TABLE and DATA_STORAGE references
6+
37
1.28.1
48
---
59
* Fix clean up config file patterns of Application Configuration Service.

src/spring/azext_spring/_deployment_deployable_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_logs_loop():
110110
sleep(10)
111111

112112
logger.warning("Trying to fetch build logs")
113-
stream_logs(client.deployments, resource_group, service,
113+
stream_logs(self.cmd, client.deployments, resource_group, service,
114114
app, deployment, logger_level_func=print)
115115
old_log_url = get_log_url()
116116
timer = Timer(3, get_logs_loop)

src/spring/azext_spring/_deployment_uploadable_factory.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, upload_url, cli_ctx):
3030
self.relative_name = relative_name
3131
self.sas_token = sas_token
3232
self.cli_ctx = cli_ctx
33+
self.upload_url = upload_url
3334

3435
def upload_and_build(self, artifact_path, **_):
3536
if not artifact_path:
@@ -41,9 +42,10 @@ def upload_and_build(self, artifact_path, **_):
4142
raise InvalidArgumentValueError('Unexpected artifact file type, must be one of .zip, .tar.gz, .tar, .jar, .war.')
4243

4344
def _upload(self, artifact_path):
44-
FileService = get_sdk(self.cli_ctx, ResourceType.DATA_STORAGE, 'file#FileService')
45-
file_service = FileService(self.account_name, sas_token=self.sas_token, endpoint_suffix=self.endpoint_suffix)
46-
file_service.create_file_from_path(self.share_name, None, self.relative_name, artifact_path)
45+
ShareFileClient = get_sdk(self.cli_ctx, ResourceType.DATA_STORAGE_FILESHARE, '_file_client#ShareFileClient')
46+
file_client = ShareFileClient.from_file_url(self.upload_url)
47+
with open(artifact_path, 'rb') as stream:
48+
file_client.upload_file(data=stream)
4749

4850

4951
class FolderUpload(FileUpload):

src/spring/azext_spring/_stream_utils.py

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
from knack.util import CLIError
1313
from knack.log import get_logger
1414
from azure.core.exceptions import HttpResponseError
15-
from azure.multiapi.storage.v2018_11_09.blob import AppendBlobService
15+
from azure.cli.core.profiles import ResourceType, get_sdk
1616
from azure.common import AzureHttpError
17-
from ._utils import get_blob_info
1817

1918
logger = get_logger(__name__)
2019

2120
DEFAULT_CHUNK_SIZE = 1024 * 4
2221
DEFAULT_LOG_TIMEOUT_IN_SEC = 60 * 30 # 30 minutes
2322

2423

25-
def stream_logs(client,
24+
def stream_logs(cmd,
25+
client,
2626
resource_group,
2727
service,
2828
app,
@@ -47,18 +47,13 @@ def stream_logs(client,
4747
logger.warning("%s Empty SAS URL.", error_msg)
4848
raise CLIError(error_msg)
4949

50-
account_name, endpoint_suffix, container_name, blob_name, sas_token = get_blob_info(
51-
log_file_sas)
50+
BlobClient = get_sdk(cmd.cli_ctx, ResourceType.DATA_STORAGE_BLOB, '_blob_client#BlobClient')
51+
blob_client = BlobClient.from_blob_url(log_file_sas)
5252

5353
_stream_logs(no_format,
5454
DEFAULT_CHUNK_SIZE,
5555
DEFAULT_LOG_TIMEOUT_IN_SEC,
56-
AppendBlobService(
57-
account_name=account_name,
58-
sas_token=sas_token,
59-
endpoint_suffix=endpoint_suffix),
60-
container_name,
61-
blob_name,
56+
blob_client,
6257
raise_error_on_failure,
6358
logger_level_func)
6459

@@ -67,8 +62,6 @@ def _stream_logs(no_format, # pylint: disable=too-many-locals, too-many-stateme
6762
byte_size,
6863
timeout_in_seconds,
6964
blob_service,
70-
container_name,
71-
blob_name,
7265
raise_error_on_failure,
7366
logger_level_func):
7467

@@ -78,7 +71,6 @@ def _stream_logs(no_format, # pylint: disable=too-many-locals, too-many-stateme
7871
stream = BytesIO()
7972
metadata = {}
8073
start = 0
81-
end = byte_size - 1
8274
available = 0
8375
sleep_time = 1
8476
max_sleep_time = 15
@@ -97,11 +89,9 @@ def safe_get_blob_properties():
9789
'''
9890
nonlocal blob_exists
9991
if not blob_exists:
100-
blob_exists = blob_service.exists(
101-
container_name=container_name, blob_name=blob_name)
92+
blob_exists = blob_service.exists()
10293
if blob_exists:
103-
return blob_service.get_blob_properties(
104-
container_name=container_name, blob_name=blob_name)
94+
return blob_service.get_blob_properties()
10595
return None
10696

10797
# Try to get the initial properties so there's no waiting.
@@ -110,7 +100,7 @@ def safe_get_blob_properties():
110100
props = safe_get_blob_properties()
111101
if props:
112102
metadata = props.metadata
113-
available = props.properties.content_length
103+
available = props.size
114104
except (AttributeError, AzureHttpError):
115105
pass
116106

@@ -123,18 +113,13 @@ def safe_get_blob_properties():
123113

124114
try:
125115
old_byte_size = len(stream.getvalue())
126-
blob_service.get_blob_to_stream(
127-
container_name=container_name,
128-
blob_name=blob_name,
129-
start_range=start,
130-
end_range=end,
131-
stream=stream)
116+
downloader = blob_service.download_blob(offset=start, length=byte_size, max_concurrency=1)
117+
downloader.readinto(stream)
132118

133119
curr_bytes = stream.getvalue()
134120
new_byte_size = len(curr_bytes)
135121
amount_read = new_byte_size - old_byte_size
136122
start += amount_read
137-
end = start + byte_size - 1
138123

139124
# Only scan what's newly read. If nothing is read, default to 0.
140125
min_scan_range = max(new_byte_size - amount_read - 1, 0)
@@ -165,7 +150,7 @@ def safe_get_blob_properties():
165150
props = safe_get_blob_properties()
166151
if props:
167152
metadata = props.metadata
168-
available = props.properties.content_length
153+
available = props.size
169154
except AzureHttpError as ae:
170155
if ae.status_code != 404:
171156
raise CLIError(ae)

src/spring/azext_spring/custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def parse_auth_flags(auth_list):
528528
def app_get_build_log(cmd, client, resource_group, service, name, deployment=None):
529529
if deployment.properties.source.type != "Source":
530530
raise CLIError("{} deployment has no build logs.".format(deployment.properties.source.type))
531-
return stream_logs(client.deployments, resource_group, service, name, deployment.name)
531+
return stream_logs(cmd, client.deployments, resource_group, service, name, deployment.name)
532532

533533

534534
def app_tail_log(cmd, client, resource_group, service, name,

src/spring/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# TODO: Confirm this is the right version number you want and it matches your
1818
# HISTORY.rst entry.
19-
VERSION = '1.28.1'
19+
VERSION = '1.28.2'
2020

2121
# The full list of classifiers is available at
2222
# https://pypi.python.org/pypi?%3Aaction=list_classifiers

0 commit comments

Comments
 (0)