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
8 changes: 6 additions & 2 deletions src/azure-cli/azure/cli/command_modules/acr/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ def acr_build(cmd, # pylint: disable=too-many-locals

platform_os, platform_arch, platform_variant = get_validate_platform(cmd, platform)

DockerBuildRequest, PlatformProperties = cmd.get_models('DockerBuildRequest', 'PlatformProperties')
DockerBuildRequest, PlatformProperties = cmd.get_models(
'DockerBuildRequest',
'PlatformProperties',
operation_group='runs')

docker_build_request = DockerBuildRequest(
agent_pool_name=agent_pool_name,
image_names=image_names,
Expand All @@ -119,7 +123,7 @@ def acr_build(cmd, # pylint: disable=too-many-locals
log_template=log_template
)

queued = LongRunningOperation(cmd.cli_ctx)(client_registries.schedule_run(
queued = LongRunningOperation(cmd.cli_ctx)(client_registries.begin_schedule_run(
resource_group_name=resource_group_name,
registry_name=registry_name,
run_request=docker_build_request))
Expand Down
41 changes: 21 additions & 20 deletions src/azure-cli/azure/cli/command_modules/acr/connected_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
"Enabling the data endpoint might affect your firewall rules.\nTo enable data endpoint run:" +
"\n\taz acr update -n {} --data-endpoint-enabled true".format(registry_name))

ErrorResponseException = cmd.get_models('ErrorResponseException')
from azure.core.exceptions import HttpResponseError as ErrorResponseException
parent = None
mode = mode.capitalize()
if parent_name:
Expand Down Expand Up @@ -129,11 +129,10 @@ def acr_connected_registry_create(cmd, # pylint: disable=too-many-locals, too-m
)

try:
return client.create(subscription_id=subscription_id,
resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name,
connected_registry_create_parameters=connected_registry_create_parameters)
return client.begin_create(resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name,
connected_registry_create_parameters=connected_registry_create_parameters)
except ValidationError as e:
raise CLIError(e)

Expand Down Expand Up @@ -202,10 +201,10 @@ def acr_connected_registry_update(cmd, # pylint: disable=too-many-locals, too-m
)

try:
return client.update(resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name,
connected_registry_update_parameters=connected_registry_update_parameters)
return client.begin_update(resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name,
connected_registry_update_parameters=connected_registry_update_parameters)
except ValidationError as e:
raise CLIError(e)

Expand All @@ -224,7 +223,7 @@ def acr_connected_registry_delete(cmd,
try:
connected_registry = acr_connected_registry_show(
cmd, client, connected_registry_name, registry_name, resource_group_name)
result = client.delete(resource_group_name, registry_name, connected_registry_name)
result = client.begin_delete(resource_group_name, registry_name, connected_registry_name)
Copy link
Member

@jiasli jiasli Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result is not polled.

Then at L237, acr_token_delete makes another client.begin_delete call. This causes Message: The subscription '00000000-0000-0000-0000-000000000000' could not be found. error: https://dev.azure.com/azclitools/public/_build/results?buildId=199090&view=logs&jobId=76ded334-3544-5630-8508-787a6cf96d29&j=76ded334-3544-5630-8508-787a6cf96d29&t=c62dd615-c6c6-5fdb-a846-07cb3711ef74

2024-10-22T02:44:50.2908872Z _________ AcrConnectedRegistryCommandsTests.test_acr_connectedregistry _________
2024-10-22T02:44:50.2909322Z [gw0] linux -- Python 3.11.8 /opt/az/bin/python3
2024-10-22T02:44:50.2909646Z self = <azure.cli.testsdk.base.ExecutionResult object at 0x7f32918d1d10>
2024-10-22T02:44:50.2910002Z cli_ctx = <azure.cli.core.mock.DummyCli object at 0x7f32929aa910>
2024-10-22T02:44:50.2910500Z command = 'acr connected-registry delete -n grandchild -r clireg000002 --cleanup -y'
2024-10-22T02:44:50.2910805Z expect_failure = False
2024-10-22T02:44:50.2910906Z 
2024-10-22T02:44:50.2911181Z     def _in_process_execute(self, cli_ctx, command, expect_failure=False):
2024-10-22T02:44:50.2911473Z         from io import StringIO
2024-10-22T02:44:50.2911788Z         from vcr.errors import CannotOverwriteExistingCassetteException
2024-10-22T02:44:50.2913231Z     
2024-10-22T02:44:50.2913589Z         if command.startswith('az '):
2024-10-22T02:44:50.2913841Z             command = command[3:]
2024-10-22T02:44:50.2914058Z     
2024-10-22T02:44:50.2914267Z         stdout_buf = StringIO()
2024-10-22T02:44:50.2914504Z         logging_buf = StringIO()
2024-10-22T02:44:50.2914724Z         try:
2024-10-22T02:44:50.2915015Z             # issue: stderr cannot be redirect in this form, as a result some failure information
2024-10-22T02:44:50.2915318Z             # is lost when command fails.
2024-10-22T02:44:50.2915626Z >           self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
2024-10-22T02:44:50.2915784Z 
2024-10-22T02:44:50.2916158Z /opt/az/lib/python3.11/site-packages/azure/cli/testsdk/base.py:302: 
2024-10-22T02:44:50.2916475Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2024-10-22T02:44:50.2917154Z /opt/az/lib/python3.11/site-packages/knack/cli.py:245: in invoke
2024-10-22T02:44:50.2917462Z     exit_code = self.exception_handler(ex)
2024-10-22T02:44:50.2917915Z /opt/az/lib/python3.11/site-packages/azure/cli/core/__init__.py:129: in exception_handler
2024-10-22T02:44:50.2918231Z     return handle_exception(ex)
2024-10-22T02:44:50.2918510Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2024-10-22T02:44:50.2918642Z 
2024-10-22T02:44:50.2919333Z ex = ResourceNotFoundError("(SubscriptionNotFound) The subscription '00000000-0000-0000-0000-000000000000' could not be found.\nCode: SubscriptionNotFound\nMessage: The subscription '00000000-0000-0000-0000-000000000000' could not be found.")
2024-10-22T02:44:50.2919782Z args = (), kwargs = {}
2024-10-22T02:44:50.2919881Z 
2024-10-22T02:44:50.2920277Z     def _handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
2024-10-22T02:44:50.2920652Z         if isinstance(ex, CannotOverwriteExistingCassetteException):
2024-10-22T02:44:50.2920998Z             # This exception usually caused by a no match HTTP request. This is a product error
2024-10-22T02:44:50.2921322Z             # that is caused by change of SDK invocation.
2024-10-22T02:44:50.2921569Z             raise ex
2024-10-22T02:44:50.2921770Z     
2024-10-22T02:44:50.2921997Z >       raise CliExecutionError(ex)
2024-10-22T02:44:50.2922374Z E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception ResourceNotFoundError during execution and fails the command.
2024-10-22T02:44:50.2922582Z 
2024-10-22T02:44:50.2922998Z /opt/az/lib/python3.11/site-packages/azure/cli/testsdk/patches.py:35: CliExecutionError
2024-10-22T02:44:50.2923169Z 
2024-10-22T02:44:50.2923431Z During handling of the above exception, another exception occurred:
2024-10-22T02:44:50.2923580Z 
2024-10-22T02:44:50.2923928Z self = <command_modules.acr.tests.latest.test_acr_connectedregistry_commands.AcrConnectedRegistryCommandsTests testMethod=test_acr_connectedregistry>
2024-10-22T02:44:50.2924399Z resource_group = 'clitest.rg000001'
2024-10-22T02:44:50.2924512Z 
2024-10-22T02:44:50.2924733Z     @ResourceGroupPreparer()
2024-10-22T02:44:50.2925019Z     def test_acr_connectedregistry(self, resource_group):
2024-10-22T02:44:50.2925327Z         # Agentpool prerequisites for connected registry testing
2024-10-22T02:44:50.2925687Z         crName = 'connectedregistry'
2024-10-22T02:44:50.2926010Z         rootName = 'rootregistry'
2024-10-22T02:44:50.2926322Z         childName = 'child'
2024-10-22T02:44:50.2926637Z         grandchildName = 'grandchild'
2024-10-22T02:44:50.2926947Z         repo1 = 'repo1'
2024-10-22T02:44:50.2927232Z         repo2 = 'repo2'
2024-10-22T02:44:50.2927510Z         repo3 = 'repo3'
2024-10-22T02:44:50.2927750Z         self.kwargs.update({
2024-10-22T02:44:50.2928127Z             'registry_name': self.create_random_name('clireg', 20),
2024-10-22T02:44:50.2928472Z             'cr_name': crName,
2024-10-22T02:44:50.2928790Z             'root_name': rootName,
2024-10-22T02:44:50.2929102Z             'child_name': childName,
2024-10-22T02:44:50.2929442Z             'grandchild_name': grandchildName,
2024-10-22T02:44:50.2929766Z             'rg_loc': 'eastus',
2024-10-22T02:44:50.2930066Z             'sku': 'Premium',
2024-10-22T02:44:50.2930380Z             'syncToken': 'syncToken',
2024-10-22T02:44:50.2930710Z             'clientToken': 'clientToken',
2024-10-22T02:44:50.2931064Z             'clientToken2': 'clientToken2',
2024-10-22T02:44:50.2931386Z             'scopeMap': 'scopeMap1',
2024-10-22T02:44:50.2931687Z             'repo_1': repo1,
2024-10-22T02:44:50.2931984Z             'repo_2': repo2,
2024-10-22T02:44:50.2932274Z             'repo_3': repo3,
2024-10-22T02:44:50.2932601Z             'syncSchedule': '0 0/10 * * *',
2024-10-22T02:44:50.2932949Z             'defaultSyncSchedule': '* * * * *',
2024-10-22T02:44:50.2933269Z             'syncWindow': 'PT4H',
2024-10-22T02:44:50.2933758Z             'notificationStr': 'hello-world:tag:push',
2024-10-22T02:44:50.2934227Z             'notificationStr2': '*:*'
2024-10-22T02:44:50.2934452Z         })
2024-10-22T02:44:50.2934689Z         # Create Registr and enable data endpoint
2024-10-22T02:44:50.2935109Z         self.cmd('acr create -n {registry_name} -g {rg} -l {rg_loc} --sku {sku}',
2024-10-22T02:44:50.2935529Z                  checks=[self.check('name', '{registry_name}'),
2024-10-22T02:44:50.2935911Z                          self.check('location', '{rg_loc}'),
2024-10-22T02:44:50.2936301Z                          self.check('adminUserEnabled', False),
2024-10-22T02:44:50.2936666Z                          self.check('sku.name', '{sku}'),
2024-10-22T02:44:50.2937034Z                          self.check('sku.tier', '{sku}'),
2024-10-22T02:44:50.2937431Z                          self.check('provisioningState', 'Succeeded')])
2024-10-22T02:44:50.2937855Z         self.cmd('acr update -n {registry_name} --data-endpoint-enabled true',
2024-10-22T02:44:50.2938277Z                  checks=self.check('dataEndpointEnabled', True))
2024-10-22T02:44:50.2938534Z     
2024-10-22T02:44:50.2938766Z         # Create a default connected registry.
2024-10-22T02:44:50.2939289Z         self.cmd('acr connected-registry create -n {cr_name} -r {registry_name} -m ReadWrite --repository {repo_1} {repo_2} {repo_3}',
2024-10-22T02:44:50.2939753Z                  checks=[self.check('name', '{cr_name}'),
2024-10-22T02:44:50.2940118Z                          self.check('mode', 'ReadWrite'),
2024-10-22T02:44:50.2940509Z                          self.check('logging.logLevel', 'Information'),
2024-10-22T02:44:50.2940915Z                          self.check('provisioningState', 'Succeeded'),
2024-10-22T02:44:50.2941297Z                          self.check('resourceGroup', '{rg}')])
2024-10-22T02:44:50.2941530Z     
2024-10-22T02:44:50.2941916Z         # Create a custom connected-registry with a previously created token.
2024-10-22T02:44:50.2942609Z         self.cmd('acr token create -r {registry_name} -n {syncToken} --repository {repo_1} content/read metadata/read --gateway {root_name} config/read config/write message/read message/write --no-passwords')
2024-10-22T02:44:50.2943264Z         self.cmd('acr token create -r {registry_name} -n {clientToken} --repository {repo_1} content/read --no-passwords')
2024-10-22T02:44:50.2944016Z         self.cmd('acr connected-registry create -n {root_name} -r {registry_name} --sync-token {syncToken} --log-level Warning -s "{syncSchedule}" -w PT4H --client-tokens {clientToken} --notifications {notificationStr}',
2024-10-22T02:44:50.2944554Z                  checks=[self.check('name', '{root_name}'),
2024-10-22T02:44:50.2944925Z                          self.check('mode', 'ReadOnly'),
2024-10-22T02:44:50.2945306Z                          self.check('provisioningState', 'Succeeded'),
2024-10-22T02:44:50.2945705Z                          self.check('logging.logLevel', 'Warning'),
2024-10-22T02:44:50.2946142Z                          self.check('parent.syncProperties.schedule', '{syncSchedule}'),
2024-10-22T02:44:50.2946633Z                          self.check('parent.syncProperties.syncWindow', '4:00:00'),
2024-10-22T02:44:50.2947053Z                          self.check('resourceGroup', '{rg}'),
2024-10-22T02:44:50.2947475Z                          self.check('notificationsList[0]', '{notificationStr}')])
2024-10-22T02:44:50.2947733Z     
2024-10-22T02:44:50.2947960Z         # Create Child connected registry
2024-10-22T02:44:50.2948472Z         self.cmd('acr connected-registry create -n {child_name} -p {root_name} -r {registry_name} --repository {repo_2} -m ReadOnly',
2024-10-22T02:44:50.2948926Z                  checks=[self.check('name', '{child_name}'),
2024-10-22T02:44:50.2949297Z                          self.check('mode', 'ReadOnly'),
2024-10-22T02:44:50.2949692Z                          self.check('provisioningState', 'Succeeded'),
2024-10-22T02:44:50.2950111Z                          self.check("ends_with(parent.id, '{root_name}')", True),
2024-10-22T02:44:50.2950712Z                          self.check('resourceGroup', '{rg}')])
2024-10-22T02:44:50.2950960Z     
2024-10-22T02:44:50.2951197Z         # Create Grandchild connected registry
2024-10-22T02:44:50.2951717Z         self.cmd('acr connected-registry create -n {grandchild_name} -p {child_name} -r {registry_name} --repository {repo_2} -m ReadOnly',
2024-10-22T02:44:50.2952511Z                  checks=[self.check('name', '{grandchild_name}'),
2024-10-22T02:44:50.2952950Z                          self.check('mode', 'ReadOnly'),
2024-10-22T02:44:50.2953374Z                          self.check('provisioningState', 'Succeeded'),
2024-10-22T02:44:50.2953854Z                          self.check("ends_with(parent.id, '{child_name}')", True),
2024-10-22T02:44:50.2954289Z                          self.check('resourceGroup', '{rg}')])
2024-10-22T02:44:50.2954550Z     
2024-10-22T02:44:50.2954801Z         # List connected registries
2024-10-22T02:44:50.2955219Z         self.cmd('acr connected-registry list -r {registry_name}',
2024-10-22T02:44:50.2955636Z                  checks=[self.check('[0].name', '{cr_name}'),
2024-10-22T02:44:50.2956045Z                          self.check('[1].name', '{root_name}')])
2024-10-22T02:44:50.2956302Z     
2024-10-22T02:44:50.2956530Z         # List client tokens
2024-10-22T02:44:50.2956987Z         self.cmd('acr connected-registry list-client-tokens -n {root_name} -r {registry_name}',
2024-10-22T02:44:50.2957444Z                  checks=[self.check('[0].name', '{clientToken}')])
2024-10-22T02:44:50.2957677Z     
2024-10-22T02:44:50.2957891Z         # Update the connected registry
2024-10-22T02:44:50.2958343Z         self.cmd('acr token create -r {registry_name} -n {clientToken2} --repository {repo_2} metadata/read --no-passwords')
2024-10-22T02:44:50.2959187Z         self.cmd('acr connected-registry update -n {root_name} -r {registry_name} --log-level Information -s "{defaultSyncSchedule}" --remove-client-tokens {clientToken} --add-client-tokens {clientToken2} --add-notifications {notificationStr2} --remove-notifications {notificationStr}',
2024-10-22T02:44:50.2959811Z                  checks=[self.check('name', '{root_name}'),
2024-10-22T02:44:50.2960205Z                          self.check('logging.logLevel', 'Information'),
2024-10-22T02:44:50.2960648Z                          self.check('parent.syncProperties.schedule', '{defaultSyncSchedule}'),
2024-10-22T02:44:50.2961117Z                          self.check('parent.syncProperties.syncWindow', 'None'),
2024-10-22T02:44:50.2961540Z                          self.check('resourceGroup', '{rg}'),
2024-10-22T02:44:50.2961997Z                          self.check('notificationsList[0]', '{notificationStr2}')])
2024-10-22T02:44:50.2962298Z     
2024-10-22T02:44:50.2962546Z         # List client tokens
2024-10-22T02:44:50.2963008Z         self.cmd('acr connected-registry list-client-tokens -n {root_name} -r {registry_name}',
2024-10-22T02:44:50.2963476Z                  checks=[self.check('[0].name', '{clientToken2}')])
2024-10-22T02:44:50.2963741Z     
2024-10-22T02:44:50.2963982Z         # Show connected registry properties
2024-10-22T02:44:50.2964436Z         self.cmd('acr connected-registry show -n {cr_name} -r {registry_name}',
2024-10-22T02:44:50.2964904Z                  checks=[self.check('name', '{cr_name}')])
2024-10-22T02:44:50.2965194Z     
2024-10-22T02:44:50.2965491Z         # Get connection string a generate new password.
2024-10-22T02:44:50.2966148Z         self.cmd('acr connected-registry get-settings -n {root_name} -r {registry_name} --parent-protocol https --generate-password 2 -y')
2024-10-22T02:44:50.2966745Z         self.cmd('acr token show -n {syncToken} -r {registry_name}', checks=[
2024-10-22T02:44:50.2967184Z             self.check('credentials.passwords[0].name', 'password2')])
2024-10-22T02:44:50.2967437Z     
2024-10-22T02:44:50.2967693Z         # Update and check connected registry repo permissions
2024-10-22T02:44:50.2968200Z         self.cmd('acr connected-registry permissions update -n {grandchild_name} -r {registry_name} --add {repo_1} {repo_3}')
2024-10-22T02:44:50.2968763Z     
2024-10-22T02:44:50.2969218Z         scope_map = self.cmd('acr connected-registry permissions show -n {root_name} -r {registry_name}').get_output_in_json()
2024-10-22T02:44:50.2969693Z         self.assertListEqual(sorted(scope_map['actions']),
2024-10-22T02:44:50.2970161Z                              ['gateway/'+ childName +'/config/read', 'gateway/'+ childName +'/config/write',
2024-10-22T02:44:50.2970675Z                               'gateway/'+ childName +'/message/read', 'gateway/'+ childName +'/message/write',
2024-10-22T02:44:50.2971199Z                               'gateway/'+ grandchildName +'/config/read', 'gateway/'+ grandchildName +'/config/write',
2024-10-22T02:44:50.2971773Z                               'gateway/'+ grandchildName +'/message/read', 'gateway/'+ grandchildName +'/message/write',
2024-10-22T02:44:50.2972329Z                               'gateway/'+ rootName +'/config/read', 'gateway/'+ rootName +'/config/write',
2024-10-22T02:44:50.2972868Z                               'gateway/'+ rootName +'/message/read', 'gateway/'+ rootName +'/message/write',
2024-10-22T02:44:50.2973421Z                               'repositories/'+ repo1 +'/content/read', 'repositories/'+ repo1 +'/metadata/read',
2024-10-22T02:44:50.2973957Z                               'repositories/'+ repo2 +'/content/read', 'repositories/'+ repo2 +'/metadata/read',
2024-10-22T02:44:50.2974504Z                               'repositories/'+ repo3 +'/content/read', 'repositories/'+ repo3 +'/metadata/read'])
2024-10-22T02:44:50.2974812Z     
2024-10-22T02:44:50.2975303Z         self.cmd('acr connected-registry permissions update -n {root_name} -r {registry_name} --remove {repo_1} {repo_2}')
2024-10-22T02:44:50.2975935Z         self.cmd('acr connected-registry permissions update -n {child_name} -r {registry_name} --remove {repo_3} --add {repo_1}')
2024-10-22T02:44:50.2976286Z     
2024-10-22T02:44:50.2976799Z         scope_map = self.cmd('acr connected-registry permissions show -n {grandchild_name} -r {registry_name}').get_output_in_json()
2024-10-22T02:44:50.2977321Z         self.assertListEqual(sorted(scope_map['actions']),
2024-10-22T02:44:50.2977867Z                              ['gateway/'+ grandchildName +'/config/read', 'gateway/'+ grandchildName +'/config/write',
2024-10-22T02:44:50.2978454Z                               'gateway/'+ grandchildName +'/message/read', 'gateway/'+ grandchildName +'/message/write'])
2024-10-22T02:44:50.2979148Z     
2024-10-22T02:44:50.2979626Z         # Delete connected registry grand child
2024-10-22T02:44:50.2980171Z >       self.cmd('acr connected-registry delete -n {grandchild_name} -r {registry_name} --cleanup -y')
2024-10-22T02:44:50.2980371Z 
2024-10-22T02:44:50.2981129Z /opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acr/tests/latest/test_acr_connectedregistry_commands.py:146: 
2024-10-22T02:44:50.2981589Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2024-10-22T02:44:50.2982090Z /opt/az/lib/python3.11/site-packages/azure/cli/testsdk/base.py:176: in cmd
2024-10-22T02:44:50.2982507Z     return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
2024-10-22T02:44:50.2983037Z /opt/az/lib/python3.11/site-packages/azure/cli/testsdk/base.py:251: in __init__
2024-10-22T02:44:50.2983428Z     self._in_process_execute(cli_ctx, command, expect_failure=expect_failure)
2024-10-22T02:44:50.2983928Z /opt/az/lib/python3.11/site-packages/azure/cli/testsdk/base.py:314: in _in_process_execute
2024-10-22T02:44:50.2984249Z     raise ex.exception
2024-10-22T02:44:50.2984641Z /opt/az/lib/python3.11/site-packages/knack/cli.py:233: in invoke
2024-10-22T02:44:50.2984960Z     cmd_result = self.invocation.execute(args)
2024-10-22T02:44:50.2985418Z /opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py:666: in execute
2024-10-22T02:44:50.2985714Z     raise ex
2024-10-22T02:44:50.2986126Z /opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py:733: in _run_jobs_serially
2024-10-22T02:44:50.2986731Z     results.append(self._run_job(expanded_arg, cmd_copy))
2024-10-22T02:44:50.2987185Z /opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py:703: in _run_job
2024-10-22T02:44:50.2987481Z     result = cmd_copy(params)
2024-10-22T02:44:50.2987885Z /opt/az/lib/python3.11/site-packages/azure/cli/core/commands/__init__.py:336: in __call__
2024-10-22T02:44:50.2988188Z     return self.handler(*args, **kwargs)
2024-10-22T02:44:50.2988613Z /opt/az/lib/python3.11/site-packages/azure/cli/core/commands/command_operation.py:121: in handler
2024-10-22T02:44:50.2988916Z     return op(**command_args)
2024-10-22T02:44:50.2989387Z /opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acr/connected_registry.py:268: in acr_connected_registry_delete
2024-10-22T02:44:50.2989791Z     acr_scope_map_delete(cmd, scope_map_client, registry_name, sync_scope_map_name, yes, resource_group_name)
2024-10-22T02:44:50.2990306Z /opt/az/lib/python3.11/site-packages/azure/cli/command_modules/acr/scope_map.py:73: in acr_scope_map_delete
2024-10-22T02:44:50.2990738Z     return client.begin_delete(resource_group_name, registry_name, scope_map_name)
2024-10-22T02:44:50.2991260Z /opt/az/lib/python3.11/site-packages/azure/core/tracing/decorator.py:94: in wrapper_use_tracer
2024-10-22T02:44:50.2991599Z     return func(*args, **kwargs)
2024-10-22T02:44:50.2992411Z /opt/az/lib/python3.11/site-packages/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_scope_maps_operations.py:635: in begin_delete
2024-10-22T02:44:50.2992840Z     raw_result = self._delete_initial(  # type: ignore
2024-10-22T02:44:50.2993441Z /opt/az/lib/python3.11/site-packages/azure/mgmt/containerregistry/v2020_11_01_preview/operations/_scope_maps_operations.py:589: in _delete_initial
2024-10-22T02:44:50.2993950Z     map_error(status_code=response.status_code, response=response, error_map=error_map)
2024-10-22T02:44:50.2994311Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2024-10-22T02:44:50.2994464Z 
2024-10-22T02:44:50.2994681Z status_code = 404
2024-10-22T02:44:50.2995161Z response = <RequestsTransportResponse: 404 Not Found, Content-Type: application/json; charset=utf-8>
2024-10-22T02:44:50.2996034Z error_map = {304: <class 'azure.core.exceptions.ResourceNotModifiedError'>, 401: <class 'azure.core.exceptions.ClientAuthenticatio..., 404: <class 'azure.core.exceptions.ResourceNotFoundError'>, 409: <class 'azure.core.exceptions.ResourceExistsError'>}
2024-10-22T02:44:50.2996387Z 
2024-10-22T02:44:50.2996614Z     def map_error(
2024-10-22T02:44:50.2996949Z         status_code: int, response: _HttpResponseCommonAPI, error_map: Mapping[int, Type[HttpResponseError]]
2024-10-22T02:44:50.2997327Z     ) -> None:
2024-10-22T02:44:50.2997561Z         if not error_map:
2024-10-22T02:44:50.2997797Z             return
2024-10-22T02:44:50.2998067Z         error_type = error_map.get(status_code)
2024-10-22T02:44:50.2998339Z         if not error_type:
2024-10-22T02:44:50.2998581Z             return
2024-10-22T02:44:50.2998845Z         error = error_type(response=response)
2024-10-22T02:44:50.2999120Z >       raise error
2024-10-22T02:44:50.2999695Z E       azure.core.exceptions.ResourceNotFoundError: (SubscriptionNotFound) The subscription '00000000-0000-0000-0000-000000000000' could not be found.
2024-10-22T02:44:50.3000079Z E       Code: SubscriptionNotFound
2024-10-22T02:44:50.3000542Z E       Message: The subscription '00000000-0000-0000-0000-000000000000' could not be found.
2024-10-22T02:44:50.3000716Z 
2024-10-22T02:44:50.3001163Z /opt/az/lib/python3.11/site-packages/azure/core/exceptions.py:161: ResourceNotFoundError

This is similar to #17185.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It even causes a test error:

https://dev.azure.com/azclitools/public/_build/results?buildId=199090&view=logs&jobId=76ded334-3544-5630-8508-787a6cf96d29&j=76ded334-3544-5630-8508-787a6cf96d29&t=c62dd615-c6c6-5fdb-a846-07cb3711ef74

2024-10-22T02:44:50.2811890Z ==================================== ERRORS ====================================
2024-10-22T02:44:50.2812330Z _ ERROR at teardown of AcrConnectedRegistryCommandsTests.test_acr_connectedregistry _
2024-10-22T02:44:50.2813027Z [gw0] linux -- Python 3.11.8 /opt/az/bin/python3
2024-10-22T02:44:50.2813530Z /opt/az/lib/python3.11/site-packages/azure/cli/testsdk/base.py:146: in tearDown
2024-10-22T02:44:50.2813893Z     super(ScenarioTest, self).tearDown()
2024-10-22T02:44:50.2814223Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2024-10-22T02:44:50.2814367Z 
2024-10-22T02:44:50.2814770Z self = <command_modules.acr.tests.latest.test_acr_connectedregistry_commands.AcrConnectedRegistryCommandsTests testMethod=test_acr_connectedregistry>
2024-10-22T02:44:50.2815030Z 
2024-10-22T02:44:50.2815272Z     def tearDown(self):
2024-10-22T02:44:50.2815553Z         os.environ = self.original_env
2024-10-22T02:44:50.2815839Z         # Autorest.Python 2.x
2024-10-22T02:44:50.2816215Z         assert not [t for t in threading.enumerate() if t.name.startswith("AzureOperationPoller")], \
2024-10-22T02:44:50.2817186Z             "You need to call 'result' or 'wait' on all AzureOperationPoller you have created"
2024-10-22T02:44:50.2817550Z         # Autorest.Python 3.x
2024-10-22T02:44:50.2817887Z >       assert not [t for t in threading.enumerate() if t.name.startswith("LROPoller")], \
2024-10-22T02:44:50.2818411Z             "You need to call 'result' or 'wait' on all LROPoller you have created"
2024-10-22T02:44:50.2818942Z E       AssertionError: You need to call 'result' or 'wait' on all LROPoller you have created
2024-10-22T02:44:50.2819126Z 
2024-10-22T02:44:50.2819611Z /opt/az/lib/python3.11/site-packages/azure/cli/testsdk/scenario_tests/base.py:160: AssertionError

sync_token = get_token_from_id(cmd, connected_registry.parent.sync_properties.token_id)
sync_token_name = sync_token.name
sync_scope_map_name = sync_token.scope_map_id.split('/scopeMaps/')[1]
Expand Down Expand Up @@ -264,14 +263,12 @@ def acr_connected_registry_deactivate(cmd,
resource_group_name=None):
_, resource_group_name = validate_managed_registry(
cmd, registry_name, resource_group_name)
subscription_id = get_subscription_id(cmd.cli_ctx)

user_confirmation("Are you sure you want to deactivate the connected registry '{}' in '{}'?".format(
connected_registry_name, registry_name), yes)
return client.deactivate(subscription_id=subscription_id,
resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name)
return client.begin_deactivate(resource_group_name=resource_group_name,
registry_name=registry_name,
connected_registry_name=connected_registry_name)


def acr_connected_registry_list(cmd,
Expand Down Expand Up @@ -355,7 +352,7 @@ def _create_sync_token(cmd,
sync_token_name = SYNC_TOKEN_NAME.format(connected_registry_name)
logger.warning("If sync token '%s' already exists, it properties will be overwritten", sync_token_name)
Token = cmd.get_models('Token')
poller = token_client.create(
poller = token_client.begin_create(
resource_group_name,
registry_name,
sync_token_name,
Expand Down Expand Up @@ -520,12 +517,16 @@ def _update_repo_permissions(cmd,
return None
current_actions = list(final_actions_set)
logger.warning(msg)
return scope_map_client.update(
ScopeMapUpdateParameters = cmd.get_models('ScopeMapUpdateParameters')
scope_map_update_parameters = ScopeMapUpdateParameters(
description=description,
actions=current_actions
)
return scope_map_client.begin_update(
resource_group_name,
registry_name,
sync_scope_map_name,
description,
current_actions
scope_map_update_parameters
)


Expand Down
9 changes: 6 additions & 3 deletions src/azure-cli/azure/cli/command_modules/acr/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def acr_pack_build(cmd, # pylint: disable=too-many-locals
raise CLIError('Building with Buildpacks requires a valid source location.')

platform_os, platform_arch, platform_variant = get_validate_platform(cmd, platform)
OS = cmd.get_models('OS')
OS = cmd.get_models('OS', operation_group='task_runs')
if platform_os != OS.linux.value.lower():
raise CLIError('Building with Buildpacks is only supported on Linux.')

Expand All @@ -74,7 +74,10 @@ def acr_pack_build(cmd, # pylint: disable=too-many-locals
pack_image_tag=pack_image_tag,
no_pull='--no-pull' if not pull else '')

EncodedTaskRunRequest, PlatformProperties = cmd.get_models('EncodedTaskRunRequest', 'PlatformProperties')
EncodedTaskRunRequest, PlatformProperties = cmd.get_models(
'EncodedTaskRunRequest',
'PlatformProperties',
operation_group='task_runs')

request = EncodedTaskRunRequest(
encoded_task_content=base64.b64encode(yaml_body.encode()).decode(),
Expand All @@ -92,7 +95,7 @@ def acr_pack_build(cmd, # pylint: disable=too-many-locals
agent_pool_name=agent_pool_name
)

queued = LongRunningOperation(cmd.cli_ctx)(client_registries.schedule_run(
queued = LongRunningOperation(cmd.cli_ctx)(client_registries.begin_schedule_run(
resource_group_name=resource_group_name,
registry_name=registry_name,
run_request=request))
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli/azure/cli/command_modules/acr/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def acr_run(cmd, # pylint: disable=too-many-locals
platform_os, platform_arch, platform_variant = get_validate_platform(cmd, platform)

EncodedTaskRunRequest, FileTaskRunRequest, PlatformProperties = cmd.get_models(
'EncodedTaskRunRequest', 'FileTaskRunRequest', 'PlatformProperties')
'EncodedTaskRunRequest', 'FileTaskRunRequest', 'PlatformProperties', operation_group='runs')

if source_location:
request = FileTaskRunRequest(
Expand Down Expand Up @@ -100,7 +100,7 @@ def acr_run(cmd, # pylint: disable=too-many-locals
log_template=log_template
)

queued = LongRunningOperation(cmd.cli_ctx)(client_registries.schedule_run(
queued = LongRunningOperation(cmd.cli_ctx)(client_registries.begin_schedule_run(
resource_group_name=resource_group_name,
registry_name=registry_name,
run_request=request))
Expand Down
22 changes: 14 additions & 8 deletions src/azure-cli/azure/cli/command_modules/acr/scope_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ def acr_scope_map_create(cmd,

actions = parse_scope_map_actions(repository_actions_list, gateway_actions_list)

scope_map = {
'actions': actions,
'description': description
}
ScopeMap = cmd.get_models('ScopeMap')

scope_map = ScopeMap(
actions=actions,
description=description
)

return client.begin_create(
resource_group_name,
Expand All @@ -68,7 +70,7 @@ def acr_scope_map_delete(cmd,
return None

resource_group_name = get_resource_group_name_by_registry_name(cmd.cli_ctx, registry_name, resource_group_name)
return client.delete(resource_group_name, registry_name, scope_map_name)
return client.begin_delete(resource_group_name, registry_name, scope_map_name)


def acr_scope_map_update(cmd,
Expand Down Expand Up @@ -106,12 +108,16 @@ def acr_scope_map_update(cmd,
final_actions_set = set(current_scope_map.actions).union(add_actions_set).difference(remove_actions_set)
current_actions = list(final_actions_set)

return client.update(
ScopeMapUpdateParameters = cmd.get_models('ScopeMapUpdateParameters')
scope_map_update_parameters = ScopeMapUpdateParameters(
description=description,
actions=current_actions
)
return client.begin_update(
resource_group_name,
registry_name,
scope_map_name,
description,
current_actions
scope_map_update_parameters
)


Expand Down