I had the same symptoms: API works locally, logs say deployment was successful, but no back end shows up in the Azure portal.
My problem was that I had a require('./some-file')
in one of my back-end JavaScript files where some-file.js
was in the .gitignore
, so it worked locally, but not when pushed.
<wall-of-text>
So—and I'm speculating here—it makes me think that if your code throws an exception while defining the endpoints AND that exception only throws in Azure (not locally), it will result in a silent failure. The artifacts are uploaded from your CI/CD pipeline to Azure, but since the error happens somewhere during deployment in Azure and not during a request to a function, you get in a state where your build pipeline thinks everything was OK even though the functions never got defined in Azure.
Evidence that supports my speculation is that adding throw new Error('NONSENSE that will break things');
in a file for the back end outside of the function/API definition results in the same exact apparent failure where the application starts, but no functions are registered—EXCEPT in this case it also fails to deploy any functions locally with errors in the logs and a message No job functions found.
, followed by a message that the CLI emulator is serving the API (even though none of the functions respond/are defined).
I replicated this across both a project deploying from GitHub Actions and from a project deploying from GitLab, and in both cases the deploy job in GitHub/GitLab was successful with clean logs, and the endpoints got busted in Azure. So, I think if you make a setup where an exception gets thrown during function definition, only "in production" (not on your machine), then you'll have the observed behavior.
Also, I tried to access logs based on the command provided by @brtrach-MSFT :
az webapp log tail --name <your-app-name> --resource-group <your-resource-group>
...however, it failed for me with the error:
(ResourceNotFound) The Resource 'Microsoft.Web/sites/MY_APP_NAME' under resource group 'MY_RESOURCE_GROUP_NAME' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
I should note that using az resource list
shows the type of my static web app as Microsoft.Web/staticSites
, which does not match Microsoft.Web/sites
—the type the az webapp
log command mentioned.
It seems that the CLI for static web apps is az staticwebapp
, but that does not have a way to inspect logs. (logs for Static Web Apps are provided by Application Insights, but I can't find a way to buy Application Insights for a project where function deployment is failing like this...)
</wall-of-text>
Based on that wall of text, I propose 2 things:
- Users of Azure Static Web Apps encountering this issue: check your project for errors that could happen during function definition — e.g.,
require()
-ing gitignored files. - Microsoft Azure team: if my speculation about the cause is correct, please make deployment jobs fail if an exception is thrown during function definition. This will both prevent bad deployments, and help debug the root cause of the problem.
Annotated screenshot of the deployment logs for a "successful" deploy where functions did not get defined due to an exception getting thrown during function definition:
I should note—this is my speculative hypothesis as a user, so I could be missing something, or your problem could be something else, but hopefully there was something helpful in here!
Edit to add: I logged a bug report in the Microsoft feedback portal to track this issue: https://feedback.azure.com/d365community/idea/ee54d1c5-59d9-ef11-95f5-6045bd80c607