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

Command 'az staticwebapp backends link' returns 500 and body {"Message":"An error has occurred."} #30860

Open
jparta opened this issue Feb 21, 2025 · 1 comment
Assignees
Labels
Auto-Assign Auto assign by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. Service Attention This issue is responsible by Azure service team. staticwebapp az staticwebapp

Comments

@jparta
Copy link

jparta commented Feb 21, 2025

Describe the bug

I'm trying to link a Function App to a Static Web App via script. The command fails with a 500 server error and the content {"Message":"An error has occurred."}. Using the debug flag I can see that this is a response to the Microsoft.Web/staticSites/<SWA_name>/builds/default/linkedBackends/ PUT request. This doesn't give me hints to debug the issue myself.

Related command

az staticwebapp backends link

Errors

cli.azure.cli.core.azclierror: An error has occurred.
az_command_data_logger: An error has occurred.

The traceback is just the handling of the HTTP 500 response internally.

Issue script & Debug output

There's no script, the command errors out on its own.

Here's the redacted debug output, with correlation and request IDs intact.

<user>@<hostname>:~/project_repos/<my-frontend>$ az staticwebapp backends link -g <resource-group> --name <staticwebapp> --backend-resource-id /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<backend-resource> --debug
cli.knack.cli: Command arguments: ['staticwebapp', 'backends', 'link', '-g', '<resource-group>', '--name', '<staticwebapp>', '--backend-resource-id', '/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<backend-resource>', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7f2c2a34f130>, <function OutputProducer.on_global_arguments at 0x7f2c2a2cb2e0>, <function CLIQuery.on_global_arguments at 0x7f2c2a114670>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'staticwebapp': ['azure.cli.command_modules.appservice']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name                  Load Time    Groups  Commands
cli.azure.cli.core: appservice                0.215        79       270
cli.azure.cli.core: Total (1)                 0.215        79       270
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name                  Load Time    Groups  Commands  Directory
cli.azure.cli.core: Total (0)                 0.000         0         0  
cli.azure.cli.core: Loaded 79 groups, 270 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command  : staticwebapp backends link
cli.azure.cli.core: Command table: staticwebapp backends link
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7f2c2961cca0>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home/<user>/.azure/commands/2025-02-21.13-38-58.staticwebapp_backends_link.112610.log'.
az_command_data_logger: command args: staticwebapp backends link -g {} --name {} --backend-resource-id {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7f2c29639870>]
cli.knack.commands: Configured default '<resource-group>' for arg resource_group_name
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7f2c2965beb0>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7f2c29498040>, <function register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x7f2c294980d0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7f2c2a2cb370>, <function CLIQuery.handle_query_parameter at 0x7f2c2a114700>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7f2c2965bf40>]
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=WebSiteManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='/home/<user>/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /home/<user>/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority: https://login.microsoftonline.com/<tenant-id>
msal.authority: openid_config("https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration") = {'token_endpoint': 'https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com/<tenant-id>/discovery/v2.0/keys', 'response_modes_supported': ['query', 'fragment', 'form_post'], 'subject_types_supported': ['pairwise'], 'id_token_signing_alg_values_supported': ['RS256'], 'response_types_supported': ['code', 'id_token', 'code id_token', 'id_token token'], 'scopes_supported': ['openid', 'profile', 'email', 'offline_access'], 'issuer': 'https://login.microsoftonline.com/<tenant-id>/v2.0', ... }
msal.application: Broker enabled? None
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_credentials: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: e45e386f-2e43-47fc-af05-0cbd155c39c8
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/staticSites/<staticwebapp>?api-version=2024-04-01'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '70365fde-f048-11ef-8ea9-69da2799f97d'
    'CommandName': 'staticwebapp backends link'
    'ParameterSetName': '-g --name --backend-resource-id --debug'
    'User-Agent': 'AZURECLI/2.69.0 (PIP) azsdk-python-core/1.32.0 Python/3.10.12 (Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.35)'
    'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/staticSites/<staticwebapp>?api-version=2024-04-01 HTTP/11" 200 1450
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '1450'
    'Content-Type': 'application/json'
    'Expires': '-1'
    'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
    'x-ms-request-id': '059959c4-e7b9-41a3-9d07-6e08cbb23756'
    ...
cli.azure.cli.core.sdk.policies: Response content:
{"id":"/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/staticSites/<staticwebapp>","name":"<staticwebapp>","type":"Microsoft.Web/staticSites","location":"West Europe","properties":{"defaultHostname":"<static-app-hostname>","repositoryUrl":"https://bitbucket.org/<org>/<my-frontend>","branch":"main","customDomains":["<custom-domain>"],"stableInboundIP":"<ip-address>","privateEndpointConnections":[],"stagingEnvironmentPolicy":"Enabled","allowConfigFileUpdates":true,"contentDistributionEndpoint":"https://content-am2.infrastructure.4.azurestaticapps.net","keyVaultReferenceIdentity":"SystemAssigned","userProvidedFunctionApps":null,"linkedBackends":[],"provider":"Custom","enterpriseGradeCdnStatus":"Disabled","publicNetworkAccess":null,"databaseConnections":[],"trafficSplitting":{"environmentDistribution":{"default":100}},"areStaticSitesDistributedBackendsEnabled":false,"targetResourceGroupResourceId":null,"trialExpirationTimeUtc":null,"prettyNameStatus":null,"prettyName":null,"prettyNameHostname":null,"backendRegion":{"regionName":null,"status":null},"stagingEnvironmentRegion":null,"deploymentAuthPolicy":"DeploymentToken","federatedIdentityTenantId":null,"federatedIdentityClientId":null,"federatedIdentitySubscriptionId":null,"deploymentStorageAccountResourceId":null,"deploymentStorageAccountReferenceIdentity":null},"sku":{"name":"Standard","tier":"Standard"}}
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=WebSiteManagementClient
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.authority: Initializing with Entra authority: https://login.microsoftonline.com/<tenant-id>
msal.authority: openid_config("https://login.microsoftonline.com/<tenant-id>/v2.0/.well-known/openid-configuration") = { ... }
msal.application: Broker enabled? None
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_credentials: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: dbd522ef-0857-4f42-969c-fbeea46081b8
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/staticSites/<staticwebapp>/builds/default/linkedBackends/<backend-resource>?api-version=2024-04-01'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
    'Content-Type': 'application/json'
    'Content-Length': '163'
    'Accept': 'application/json'
    'x-ms-client-request-id': '70365fde-f048-11ef-8ea9-69da2799f97d'
    'CommandName': 'staticwebapp backends link'
    'ParameterSetName': '-g --name --backend-resource-id --debug'
    'User-Agent': 'AZURECLI/2.69.0 (PIP) azsdk-python-core/1.32.0 Python/3.10.12 (Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.35)'
    'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
{"properties": {"backendResourceId": "/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<backend-resource>"}}
urllib3.connectionpool: Starting new HTTPS connection (2): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/staticSites/<staticwebapp>/builds/default/linkedBackends/<backend-resource>?api-version=2024-04-01 HTTP/11" 500 36
cli.azure.cli.core.sdk.policies: Response status: 500
cli.azure.cli.core.sdk.policies: Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '36'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
    'x-ms-failure-cause': 'service'
    'x-ms-ratelimit-remaining-subscription-writes': '199'
    'x-ms-ratelimit-remaining-subscription-global-writes': '2999'
    'x-ms-request-id': 'd5365a79-177d-48e2-aaa3-eddf36d94aed'
    'x-ms-correlation-request-id': 'd5365a79-177d-48e2-aaa3-eddf36d94aed'
    ...
cli.azure.cli.core.sdk.policies: Response content:
Body is streamable
[... additional repeated PUT attempts with identical redactions ...]
azure.mgmt.web._serialization: Ran into a deserialization error. Ignoring since this is failsafe deserialization
Traceback (most recent call last):
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/mgmt/web/_serialization.py", line 1627, in failsafe_deserialize
    return self(target_obj, data, content_type=content_type)
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/mgmt/web/_serialization.py", line 1494, in __call__
    return self.handler(target_obj, data, content_type=content_type)
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/mgmt/web/_serialization.py", line 1658, in _unpack_content
    raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize")
ValueError: This pipeline didn't have the RawDeserializer policy; can't deserialize
cli.azure.cli.core.azclierror: Traceback (most recent call last):
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/cli/command_modules/appservice/static_sites.py", line 717, in link_backend
    return client.begin_link_backend_to_build(
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/core/tracing/decorator.py", line 105, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/mgmt/web/v2024_04_01/operations/_static_sites_operations.py", line 11378, in begin_link_backend_to_build
    raw_result = self._link_backend_to_build_initial(
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/mgmt/web/v2024_04_01/operations/_static_sites_operations.py", line 11252, in _link_backend_to_build_initial
    raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Internal Server Error'
Content: {"Message":"An error has occurred."}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/<user>/.local/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_job
    return cmd_copy.exception_handler(ex)
  File "/home/<user>/.local/lib/python3.10/site-packages/azure/cli/command_modules/appservice/commands.py", line 46, in _ex_handler
    raise ex
knack.util.CLIError: An error has occurred.

cli.azure.cli.core.azclierror: An error has occurred.
az_command_data_logger: An error has occurred.
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7f2c2961cee0>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 9.324 seconds (init: 0.089, invoke: 9.234)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 3958 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/usr/bin/python3 /home/<user>/.local/lib/python3.10/site-packages/azure/cli/telemetry/__init__.py /home/<user>/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.


Expected behavior

Link the Function App to the Static Web App successfully.

Environment Summary

azure-cli                         2.69.0

core                              2.69.0
telemetry                          1.1.0

Extensions:
acrquery                           1.0.1

Dependencies:
msal                            1.31.2b1
azure-mgmt-resource               23.1.1

Python location '/usr/bin/python3'
Config directory '/home/<user>/.azure'
Extensions directory '/home/<user>/.azure/cliextensions'

Python (Linux) 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

Additional context

I'm running in WSL. I don't know if that affects this error.

@jparta jparta added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Feb 21, 2025
@yonzhan
Copy link
Collaborator

yonzhan commented Feb 21, 2025

Thank you for opening this issue, we will look into it.

@microsoft-github-policy-service microsoft-github-policy-service bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. Auto-Assign Auto assign by bot labels Feb 21, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the staticwebapp az staticwebapp label Feb 21, 2025
@yonzhan yonzhan added the Service Attention This issue is responsible by Azure service team. label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot bug This issue requires a change to an existing behavior in the product in order to be resolved. customer-reported Issues that are reported by GitHub users external to the Azure organization. Service Attention This issue is responsible by Azure service team. staticwebapp az staticwebapp
Projects
None yet
Development

No branches or pull requests

6 participants