Azure / Azure/azure-cli

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

Open
#30,860 3 comments 0 reactions 4 assignees Claimed by @mkarmark View on GitHub
act-observability-squad Auto-Assign bug customer-reported Service Attention staticwebapp
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### 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//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.

```
@:~/project_repos/$ az staticwebapp backends link -g --name --backend-resource-id /subscriptions//resourceGroups//providers/Microsoft.Web/sites/ --debug
cli.knack.cli: Command arguments: ['staticwebapp', 'backends', 'link', '-g', '', '--name', '', '--backend-resource-id', '/subscriptions//resourceGroups//providers/Microsoft.Web/sites/', '--debug']
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
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 []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/home//.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 [.add_subscription_parameter at 0x7f2c29639870>]
cli.knack.commands: Configured default '' for arg resource_group_name
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x7f2c2965beb0>, .add_cache_arguments at 0x7f2c29498040>, .update_breaking_change_info at 0x7f2c294980d0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .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//.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /home//.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/
msal.authority: openid_config("https://login.microsoftonline.com//v2.0/.well-known/openid-configuration") = {'token_endpoint': 'https://login.microsoftonline.com//oauth2/v2.0/token', 'token_endpoint_auth_methods_supported': ['client_secret_post', 'private_key_jwt', 'client_secret_basic'], 'jwks_uri': 'https://login.microsoftonline.com//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//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//resourceGroups//providers/Microsoft.Web/staticSites/?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//resourceGroups//providers/Microsoft.Web/staticSites/?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//resourceGroups//providers/Microsoft.Web/staticSites/","name":"","type":"Microsoft.Web/staticSites","location":"West Europe","properties":{"defaultHostname":"","repositoryUrl":"https://bitbucket.org//","branch":"main","customDomains":[""],"stableInboundIP":"","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/
msal.authority: openid_config("https://login.microsoftonline.com//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//resourceGroups//providers/Microsoft.Web/staticSites//builds/default/linkedBackends/?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//resourceGroups//providers/Microsoft.Web/sites/"}}
urllib3.connectionpool: Starting new HTTPS connection (2): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions//resourceGroups//providers/Microsoft.Web/staticSites//builds/default/linkedBackends/?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//.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//.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//.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//.local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
result = cmd_copy(params)
File "/home//.local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
return self.handler(*args, **kwargs)
File "/home//.local/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
File "/home//.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//.local/lib/python3.10/site-packages/azure/core/tracing/decorator.py", line 105, in wrapper_use_tracer
return func(*args, **kwargs)
File "/home//.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//.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//.local/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/home//.local/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
raise ex
File "/home//.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//.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//.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 []
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//.local/lib/python3.10/site-packages/azure/cli/telemetry/__init__.py /home//.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//.azure'
Extensions directory '/home//.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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.