Skip to content

az webapp deployment source looks for user even if it is called by a Service Prinicpal #30021

Description

@erik-toger

Describe the bug

When calling this command from my github workflow:

 - name: Create source control directly
   run: "az webapp deployment source config --name <web-app-name> --resource-group <RG-name> --repo-url <repo-url> --branch main --github-action true"

I get: ERROR: Cannot find User with name

I am logged in with a service principal and not a user:

- name: Az CLI login
        uses: azure/login@v2
        with:
          client-id: ${{ secrets.AZURE_SP_CLIENT_ID }}
          tenant-id: ${{ secrets.AZURE_TENANT_ID }}
          subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

Related command

az webapp deployment source config

Errors

ERROR: Cannot find User with name

Issue script & Debug output

DEBUG: cli.azure.cli.core.sdk.policies: Request method: 'PUT'
DEBUG: cli.azure.cli.core.sdk.policies: Request headers:
DEBUG: cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json'
DEBUG: cli.azure.cli.core.sdk.policies: 'Content-Length': '137'
DEBUG: cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': ''
DEBUG: cli.azure.cli.core.sdk.policies: 'CommandName': 'webapp deployment source config'
DEBUG: cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--name --resource-group --repo-url --branch --github-action --debug'
DEBUG: cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.64.0 (DEB) azsdk-python-core/1.28.0 Python/3.11.8 (Linux-6.8.0-1014-azure-x86_64-with-glibc2.35)'
DEBUG: cli.azure.cli.core.sdk.policies: 'Authorization': '
'
DEBUG: cli.azure.cli.core.sdk.policies: Request body:
DEBUG: cli.azure.cli.core.sdk.policies: {"properties": {"repoUrl": "https://github.com/****/", "branch": "main", "isGitHubAction": true, "isMercurial": false}}
DEBUG: urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
DEBUG: urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/
/resourceGroups/
/providers/Microsoft.Web/sites/*/sourcecontrols/web?api-version=2023-01-01 HTTP/1.1" 404 487
DEBUG: cli.azure.cli.core.sdk.policies: Response status: 404
DEBUG: cli.azure.cli.core.sdk.policies: Response headers:
DEBUG: cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
DEBUG: cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
DEBUG: cli.azure.cli.core.sdk.policies: 'Content-Length': '487'
DEBUG: cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
DEBUG: cli.azure.cli.core.sdk.policies: 'Expires': '-1'
DEBUG: cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-AspNet-Version': '4.0.30319'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-Powered-By': 'ASP.NET'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-writes': '199'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-global-writes': '2999'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-request-id': ''
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '
'
DEBUG: cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': ':20241002T081706Z:'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
DEBUG: cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: ***** Ref B: ***** Ref C: 2024-10-02T08:17:06Z'
DEBUG: cli.azure.cli.core.sdk.policies: 'Date': 'Wed, 02 Oct 2024 08:17:06 GMT'
DEBUG: cli.azure.cli.core.sdk.policies: Response content:
DEBUG: cli.azure.cli.core.sdk.policies: {"Code":"NotFound","Message":"Cannot find User with name *****.","Target":null,"Details":[{"Message":"Cannot find User with name ."},{"Code":"NotFound"},{"ErrorEntity":{"ExtendedCode":"51004","MessageTemplate":"Cannot find {0} with name {1}.","Parameters":["User",""],"Code":"NotFound","Message":"Cannot find User with name *****."}}],"Innererror":null}
DEBUG: cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 703, in _run_job
result = cmd_copy(params)
^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 336, in call
return self.handler(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/appservice/custom.py", line 2643, in config_source_control
poller = _generic_site_operation(cmd.cli_ctx, resource_group_name, name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/appservice/_appservice_utils.py", line 21, in _generic_site_operation
if extra_parameter is None else operation(resource_group_name,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/core/tracing/decorator.py", line 76, in wrapper_use_tracer
return func(*args, **kwargs)
File "/opt/az/lib/python3.11/site-packages/azure/mgmt/web/v2023_01_01/operations/_web_apps_operations.py", line 55883, in begin_create_or_update_source_control
raw_result = self._create_or_update_source_control_initial(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/mgmt/web/v2023_01_01/operations/_web_apps_operations.py", line 55740, in _create_or_update_source_control_initial
map_error(status_code=response.status_code, response=response, error_map=error_map)
File "/opt/az/lib/python3.11/site-packages/azure/core/exceptions.py", line 112, in map_error
raise error
azure.core.exceptions.ResourceNotFoundError: Operation returned an invalid status 'Not Found'
Content: {"Code":"NotFound","Message":"Cannot find User with name *****.","Target":null,"Details":[{"Message":"Cannot find User with name ."},{"Code":"NotFound"},{"ErrorEntity":{"ExtendedCode":"51004","MessageTemplate":"Cannot find {0} with name {1}.","Parameters":["User",""],"Code":"NotFound","Message":"Cannot find User with name *****."}}],"Innererror":null}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 666, in execute
raise ex
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 733, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 725, in _run_job
return cmd_copy.exception_handler(ex)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/az/lib/python3.11/site-packages/azure/cli/command_modules/appservice/commands.py", line 46, in _ex_handler
raise ex
knack.util.CLIError: Cannot find User with name *****.

ERROR: cli.azure.cli.core.azclierror: Cannot find User with name *****.
ERROR: az_command_data_logger: Cannot find User with name *****.
DEBUG: cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f3394cd5f80>]
INFO: az_command_data_logger: exit code: 1
INFO: cli.main: Command ran in 3.601 seconds (init: 0.118, invoke: 3.482)
INFO: telemetry.main: Begin splitting cli events and extra events, total events: 1
INFO: telemetry.client: Accumulated 0 events. Flush the clients.
INFO: telemetry.main: Finish splitting cli events and extra events.
INFO: telemetry.save: Save telemetry record of length 3923 in cache file under /home/runner/.azure/telemetry/20241002081707190
INFO: telemetry.main: Begin creating telemetry upload process.
INFO: telemetry.process: Creating upload process: "/opt/az/bin/python3 /opt/az/lib/python3.11/site-packages/azure/cli/telemetry/init.py

Expected behavior

That the command use the Id to look up a Service Principal not user, so that I can create a source control resource via github workflow.

Environment Summary

azure-cli 2.64.0
core 2.64.0
telemetry 1.1.0
Extensions:
azure-devops 1.0.1
Dependencies:
msal 1.30.0
azure-mgmt-resource 23.1.1
Python location '/opt/az/bin/python3'
Extensions directory '/opt/az/azcliextensions'
Python (Linux) 3.11.8 (main, Aug 28 2024, 05:45:18) [GCC 11.4.0]
Legal docs and information: aka.ms/AzureCliLegal
Your CLI is up-to-date.

Additional context

Right now I have to do it from the command line logged in as a user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Auto-AssignAuto assign by botService AttentionThis issue is responsible by Azure service team.Web Appsaz webappact-observability-squadapp-service-deploymentbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions