Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AppServices] Get the site information to retrieve the ARM resource Id and location #30364

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

vkarasala
Copy link
Contributor

Get site to retrieve the ARM resource id and location

Related command

Description

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


This checklist is used to make sure that common guidelines for a pull request are followed.

Get site to retrieve the ARM resource id and location
Copy link

azure-client-tools-bot-prd bot commented Nov 15, 2024

❌AzureCLI-FullTest
️✔️acr
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
❌appservice
❌latest
❌3.12
Type Test Case Error Message Line
Failed test_restore_snapshot api_profile = <MagicMock name='mock.cloud.profile' id='139682950084128'>
resource_type = <ResourceType.MGMT_APPSERVICE: ('azure.mgmt.web', 'WebSiteManagementClient')>
as_sdk_profile = True

    def get_api_version(api_profile, resource_type, as_sdk_profile=False):
        """Get the API version of a resource type given an API profile.
    
        :param api_profile: The name of the API profile.
        :type api_profile: str.
        :param resource_type: The resource type.
        :type resource_type: ResourceType.
        :returns:  str -- the API version.
        :raises: APIVersionException
        """
        try:
>           api_version = AZURE_API_PROFILES[api_profile][resource_type]
E           KeyError: <MagicMock name='mock.cloud.profile' id='139682950084128'>

src/azure-cli-core/azure/cli/core/profiles/shared.py:502: KeyError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.appservice.tests.latest.test_webapp_commands_thru_mock.TestWebappMocked testMethod=test_restore_snapshot>
client_factory_mock = <function web_client_factory at 0x7f0a78686ac0>

    @mock.patch('azure.cli.command_modules.appservice.custom.web_client_factory', autospec=True)
    def test_restore_snapshot(self, client_factory_mock):
        cmd_mock = get_test_cmd()
        cli_ctx_mock = mock.MagicMock()
        cli_ctx_mock.data = {'subscription_id': 'sub1'}
        cmd_mock.cli_ctx = cli_ctx_mock
    
        client = mock.MagicMock()
        client.web_apps.restore_snapshot_slot = mock.MagicMock()
        client.web_apps.restore_snapshot = mock.MagicMock()
        client_factory_mock.return_value = client
    
        SnapshotRecoverySource, SnapshotRestoreRequest = <br>            cmd_mock.get_models('SnapshotRecoverySource', 'SnapshotRestoreRequest')
        source = SnapshotRecoverySource(id='/subscriptions/sub1/resourceGroups/src_rg/providers/Microsoft.Web/sites/src_web/slots/src_slot', location = 'location')
        request = SnapshotRestoreRequest(overwrite=False, snapshot_time='2018-12-07T02:01:31.4708832Z',
                                         recovery_source=source, recover_configuration=False)
        overwrite_request = SnapshotRestoreRequest(overwrite=True, snapshot_time='2018-12-07T02:01:31.4708832Z', recover_configuration=True)
    
        # action
>       restore_snapshot(cmd_mock, 'rg', 'web1', '2018-12-07T02:01:31.4708832Z', slot='slot1', restore_content_only=True,
                         source_resource_group='src_rg', source_name='src_web', source_slot='src_slot')

src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py:374: 
 
                                       
src/azure-cli/azure/cli/command_modules/appservice/custom.py:2987: in restore_snapshot
    webapp = generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'get', slot)
src/azure-cli/azure/cli/command_modules/appservice/appservice_utils.py:16: in generic_site_operation
    client = client or web_client_factory(cli_ctx, api_version=api_version)
src/azure-cli/azure/cli/command_modules/appservice/client_factory.py:30: in web_client_factory
    return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_APPSERVICE, api_version=api_version)
src/azure-cli-core/azure/cli/core/commands/client_factory.py:76: in get_mgmt_service_client
    api_version = api_version or get_api_version(cli_ctx, client_or_resource_type, as_sdk_profile=True)
src/azure-cli-core/azure/cli/core/profiles/init.py:22: in get_api_version
    return sdk_get_api_version(cli_ctx.cloud.profile, resource_type, as_sdk_profile)
 
 
 
 
                                   _ 

api_profile = <MagicMock name='mock.cloud.profile' id='139682950084128'>
resource_type = <ResourceType.MGMT_APPSERVICE: ('azure.mgmt.web', 'WebSiteManagementClient')>
as_sdk_profile = True

    def get_api_version(api_profile, resource_type, as_sdk_profile=False):
        """Get the API version of a resource type given an API profile.
    
        :param api_profile: The name of the API profile.
        :type api_profile: str.
        :param resource_type: The resource type.
        :type resource_type: ResourceType.
        :returns:  str -- the API version.
        :raises: APIVersionException
        """
        try:
            api_version = AZURE_API_PROFILES[api_profile][resource_type]
            if as_sdk_profile:
                return api_version  # Could be SDKProfile or string
            if isinstance(api_version, SDKProfile):
                api_version = _get_api_version_tuple(resource_type, api_version)
            return api_version
        except KeyError:
>           raise APIVersionException(resource_type, api_profile)
E           azure.cli.core.profiles._shared.APIVersionException: Unable to get API version for type 'ResourceType.MGMT_APPSERVICE' in profile '<MagicMock name='mock.cloud.profile' id='139682950084128'>'

src/azure-cli-core/azure/cli/core/profiles/_shared.py:509: APIVersionException
azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py:353
❌3.9
Type Test Case Error Message Line
Failed test_restore_snapshot api_profile = <MagicMock name='mock.cloud.profile' id='140622811512064'>
resource_type = <ResourceType.MGMT_APPSERVICE: ('azure.mgmt.web', 'WebSiteManagementClient')>
as_sdk_profile = True

    def get_api_version(api_profile, resource_type, as_sdk_profile=False):
        """Get the API version of a resource type given an API profile.
    
        :param api_profile: The name of the API profile.
        :type api_profile: str.
        :param resource_type: The resource type.
        :type resource_type: ResourceType.
        :returns:  str -- the API version.
        :raises: APIVersionException
        """
        try:
>           api_version = AZURE_API_PROFILES[api_profile][resource_type]
E           KeyError: <MagicMock name='mock.cloud.profile' id='140622811512064'>

src/azure-cli-core/azure/cli/core/profiles/shared.py:502: KeyError

During handling of the above exception, another exception occurred:

self = <azure.cli.command_modules.appservice.tests.latest.test_webapp_commands_thru_mock.TestWebappMocked testMethod=test_restore_snapshot>
client_factory_mock = <function web_client_factory at 0x7fe54cbda940>

    @mock.patch('azure.cli.command_modules.appservice.custom.web_client_factory', autospec=True)
    def test_restore_snapshot(self, client_factory_mock):
        cmd_mock = get_test_cmd()
        cli_ctx_mock = mock.MagicMock()
        cli_ctx_mock.data = {'subscription_id': 'sub1'}
        cmd_mock.cli_ctx = cli_ctx_mock
    
        client = mock.MagicMock()
        client.web_apps.restore_snapshot_slot = mock.MagicMock()
        client.web_apps.restore_snapshot = mock.MagicMock()
        client_factory_mock.return_value = client
    
        SnapshotRecoverySource, SnapshotRestoreRequest = <br>            cmd_mock.get_models('SnapshotRecoverySource', 'SnapshotRestoreRequest')
        source = SnapshotRecoverySource(id='/subscriptions/sub1/resourceGroups/src_rg/providers/Microsoft.Web/sites/src_web/slots/src_slot', location = 'location')
        request = SnapshotRestoreRequest(overwrite=False, snapshot_time='2018-12-07T02:01:31.4708832Z',
                                         recovery_source=source, recover_configuration=False)
        overwrite_request = SnapshotRestoreRequest(overwrite=True, snapshot_time='2018-12-07T02:01:31.4708832Z', recover_configuration=True)
    
        # action
>       restore_snapshot(cmd_mock, 'rg', 'web1', '2018-12-07T02:01:31.4708832Z', slot='slot1', restore_content_only=True,
                         source_resource_group='src_rg', source_name='src_web', source_slot='src_slot')

src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py:374: 
 
                                       
src/azure-cli/azure/cli/command_modules/appservice/custom.py:2987: in restore_snapshot
    webapp = generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'get', slot)
src/azure-cli/azure/cli/command_modules/appservice/appservice_utils.py:16: in generic_site_operation
    client = client or web_client_factory(cli_ctx, api_version=api_version)
src/azure-cli/azure/cli/command_modules/appservice/client_factory.py:30: in web_client_factory
    return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_APPSERVICE, api_version=api_version)
src/azure-cli-core/azure/cli/core/commands/client_factory.py:76: in get_mgmt_service_client
    api_version = api_version or get_api_version(cli_ctx, client_or_resource_type, as_sdk_profile=True)
src/azure-cli-core/azure/cli/core/profiles/init.py:22: in get_api_version
    return sdk_get_api_version(cli_ctx.cloud.profile, resource_type, as_sdk_profile)
 
 
 
 
                                   _ 

api_profile = <MagicMock name='mock.cloud.profile' id='140622811512064'>
resource_type = <ResourceType.MGMT_APPSERVICE: ('azure.mgmt.web', 'WebSiteManagementClient')>
as_sdk_profile = True

    def get_api_version(api_profile, resource_type, as_sdk_profile=False):
        """Get the API version of a resource type given an API profile.
    
        :param api_profile: The name of the API profile.
        :type api_profile: str.
        :param resource_type: The resource type.
        :type resource_type: ResourceType.
        :returns:  str -- the API version.
        :raises: APIVersionException
        """
        try:
            api_version = AZURE_API_PROFILES[api_profile][resource_type]
            if as_sdk_profile:
                return api_version  # Could be SDKProfile or string
            if isinstance(api_version, SDKProfile):
                api_version = _get_api_version_tuple(resource_type, api_version)
            return api_version
        except KeyError:
>           raise APIVersionException(resource_type, api_profile)
E           azure.cli.core.profiles._shared.APIVersionException: Unable to get API version for type 'ResourceType.MGMT_APPSERVICE' in profile '<MagicMock name='mock.cloud.profile' id='140622811512064'>'

src/azure-cli-core/azure/cli/core/profiles/_shared.py:509: APIVersionException
azure/cli/command_modules/appservice/tests/latest/test_webapp_commands_thru_mock.py:353
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9

Copy link

azure-client-tools-bot-prd bot commented Nov 15, 2024

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Collaborator

yonzhan commented Nov 15, 2024

Thank you for your contribution! We will review the pull request and get back to you soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants