Skip to content

Commit 3cc5311

Browse files
authored
{Storage} Remove DATA_STORAGE and DATA_COSMOS_TABLE client type reference (#31583)
1 parent 125ab87 commit 3cc5311

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1525
-1800
lines changed

src/azure-cli-core/azure/cli/core/commands/client_factory.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from azure.cli.core import _debug
77
from azure.cli.core.auth.util import resource_to_scopes
88
from azure.cli.core.extension import EXTENSIONS_MOD_PREFIX
9-
from azure.cli.core.profiles import ResourceType, CustomResourceType, get_api_version, get_sdk
9+
from azure.cli.core.profiles import ResourceType, CustomResourceType, get_api_version
1010
from azure.cli.core.profiles._shared import get_client_class, SDKProfile
1111
from azure.cli.core.util import get_az_user_agent, is_track2
1212
from knack.log import get_logger
@@ -275,8 +275,8 @@ def get_data_service_client(cli_ctx, service_type, account_name, account_key, co
275275
if location_mode:
276276
client.location_mode = location_mode
277277
except ValueError as exc:
278-
_ERROR_STORAGE_MISSING_INFO = get_sdk(cli_ctx, ResourceType.DATA_STORAGE,
279-
'common._error#_ERROR_STORAGE_MISSING_INFO')
278+
_ERROR_STORAGE_MISSING_INFO = ('You need to provide an account name and either an account_key or sas_token '
279+
'when creating a storage service.')
280280
if _ERROR_STORAGE_MISSING_INFO in str(exc):
281281
raise ValueError(exc)
282282
raise CLIError('Unable to obtain data client. Check your connection parameters.')

src/azure-cli-core/azure/cli/core/profiles/_shared.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class ResourceType(Enum): # pylint: disable=too-few-public-methods
8989
# can be provided with "ResourceType.XXX" to initialize the client object. This usually happens
9090
# when related commands start to support Multi-API
9191

92-
DATA_COSMOS_TABLE = ('azure.multiapi.cosmosdb', None)
9392
MGMT_ADVISOR = ('azure.mgmt.advisor', None)
9493
MGMT_MEDIA = ('azure.mgmt.media', None)
9594
MGMT_BACKUP = ('azure.mgmt.recoveryservicesbackup', None)
@@ -116,7 +115,6 @@ class ResourceType(Enum): # pylint: disable=too-few-public-methods
116115
MGMT_SQLVM = ('azure.mgmt.sqlvirtualmachine', None)
117116
MGMT_MANAGEDSERVICES = ('azure.mgmt.managedservices', None)
118117
MGMT_NETAPPFILES = ('azure.mgmt.netappfiles', None)
119-
DATA_STORAGE = ('azure.multiapi.storage', None)
120118
DATA_STORAGE_BLOB = ('azure.multiapi.storagev2.blob', None)
121119
DATA_STORAGE_FILEDATALAKE = ('azure.multiapi.storagev2.filedatalake', None)
122120
DATA_STORAGE_FILESHARE = ('azure.multiapi.storagev2.fileshare', None)
@@ -206,12 +204,10 @@ def default_api_version(self):
206204
ResourceType.DATA_KEYVAULT_ADMINISTRATION_SETTING: None,
207205
ResourceType.DATA_KEYVAULT_ADMINISTRATION_BACKUP: '7.5-preview.1',
208206
ResourceType.DATA_KEYVAULT_ADMINISTRATION_ACCESS_CONTROL: '7.4',
209-
ResourceType.DATA_STORAGE: '2018-11-09',
210207
ResourceType.DATA_STORAGE_BLOB: '2022-11-02',
211208
ResourceType.DATA_STORAGE_FILEDATALAKE: '2021-08-06',
212209
ResourceType.DATA_STORAGE_FILESHARE: '2025-05-05',
213210
ResourceType.DATA_STORAGE_QUEUE: '2018-03-28',
214-
ResourceType.DATA_COSMOS_TABLE: '2017-04-17',
215211
ResourceType.DATA_STORAGE_TABLE: None,
216212
ResourceType.MGMT_SERVICEBUS: None,
217213
ResourceType.MGMT_EVENTHUB: None,

src/azure-cli/azure/cli/command_modules/acr/_stream_utils.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from azure.core.exceptions import HttpResponseError
1313
from azure.common import AzureHttpError
1414
from azure.cli.core.profiles import ResourceType, get_sdk
15-
from ._azure_utils import get_blob_info
1615
from ._constants import ACR_RUN_DEFAULT_TIMEOUT_IN_SEC
1716

1817
logger = get_logger(__name__)
@@ -50,20 +49,14 @@ def stream_logs(cmd, client,
5049
raise CLIError(error_msg)
5150

5251
if not artifact:
53-
account_name, endpoint_suffix, container_name, blob_name, sas_token = get_blob_info(
54-
log_file_sas)
55-
AppendBlobService = get_sdk(cmd.cli_ctx, ResourceType.DATA_STORAGE, 'blob#AppendBlobService')
52+
BlobClient = get_sdk(cmd.cli_ctx, ResourceType.DATA_STORAGE_BLOB, '_blob_client#BlobClient')
53+
blob_client = BlobClient.from_blob_url(log_file_sas)
5654
if not timeout:
5755
timeout = ACR_RUN_DEFAULT_TIMEOUT_IN_SEC
5856
_stream_logs(no_format,
5957
DEFAULT_CHUNK_SIZE,
6058
timeout,
61-
AppendBlobService(
62-
account_name=account_name,
63-
sas_token=sas_token,
64-
endpoint_suffix=endpoint_suffix),
65-
container_name,
66-
blob_name,
59+
blob_client,
6760
raise_error_on_failure)
6861
else:
6962
_stream_artifact_logs(log_file_sas,
@@ -74,8 +67,6 @@ def _stream_logs(no_format, # pylint: disable=too-many-locals, too-many-stateme
7467
byte_size,
7568
timeout_in_seconds,
7669
blob_service,
77-
container_name,
78-
blob_name,
7970
raise_error_on_failure):
8071

8172
if not no_format:
@@ -85,7 +76,6 @@ def _stream_logs(no_format, # pylint: disable=too-many-locals, too-many-stateme
8576
stream = BytesIO()
8677
metadata = {}
8778
start = 0
88-
end = byte_size - 1
8979
available = 0
9080
sleep_time = 1
9181
max_sleep_time = 15
@@ -97,14 +87,12 @@ def _stream_logs(no_format, # pylint: disable=too-many-locals, too-many-stateme
9787
# If the storage call fails, we'll just sleep and try again after.
9888
try:
9989
# Need to call "exists" API to prevent storage SDK logging BlobNotFound error
100-
log_exist = blob_service.exists(
101-
container_name=container_name, blob_name=blob_name)
90+
log_exist = blob_service.exists()
10291

10392
if log_exist:
104-
props = blob_service.get_blob_properties(
105-
container_name=container_name, blob_name=blob_name)
93+
props = blob_service.get_blob_properties()
10694
metadata = props.metadata
107-
available = props.properties.content_length
95+
available = props.size
10896
else:
10997
# Wait a little bit before checking the existence again
11098
time.sleep(1)
@@ -120,18 +108,13 @@ def _stream_logs(no_format, # pylint: disable=too-many-locals, too-many-stateme
120108

121109
try:
122110
old_byte_size = len(stream.getvalue())
123-
blob_service.get_blob_to_stream(
124-
container_name=container_name,
125-
blob_name=blob_name,
126-
start_range=start,
127-
end_range=end,
128-
stream=stream)
111+
downloader = blob_service.download_blob(offset=start, length=byte_size, max_concurrency=1)
112+
downloader.readinto(stream)
129113

130114
curr_bytes = stream.getvalue()
131115
new_byte_size = len(curr_bytes)
132116
amount_read = new_byte_size - old_byte_size
133117
start += amount_read
134-
end = start + byte_size - 1
135118

136119
# Only scan what's newly read. If nothing is read, default to 0.
137120
min_scan_range = max(new_byte_size - amount_read - 1, 0)
@@ -153,13 +136,11 @@ def _stream_logs(no_format, # pylint: disable=too-many-locals, too-many-stateme
153136

154137
try:
155138
if log_exist:
156-
props = blob_service.get_blob_properties(
157-
container_name=container_name, blob_name=blob_name)
139+
props = blob_service.get_blob_properties()
158140
metadata = props.metadata
159-
available = props.properties.content_length
141+
available = props.size
160142
else:
161-
log_exist = blob_service.exists(
162-
container_name=container_name, blob_name=blob_name)
143+
log_exist = blob_service.exists()
163144
except AzureHttpError as ae:
164145
if ae.status_code != 404:
165146
raise CLIError(ae)

0 commit comments

Comments
 (0)