Deploying the API succeds on build, but no API is presented in Azure?

Martin Hinshelwood nkdAgility.com 5 Reputation points MVP
2024-11-01T13:15:19.4766667+00:00

I'm having a problem with the API deployment and I don't see any error messages. It looks like its deploying the API, but in the APIs tab does not show any active APIs.

Image

Why might this be the case? What else can I look at to debug?


staticwebapp.config.json: https://github.com/nkdAgility/NKDAgility.com/blob/54-update-courses-data/staticwebapp.config.json


{

  "platform": {

    "apiRuntime": "dotnet-isolated:8.0"

  }

}

Build: https://github.com/nkdAgility/NKDAgility.com/blob/54-update-courses-data/.github/workflows/main.yaml


- name: Build and Deploy

        uses: Azure/static-web-apps-deploy@v1

        id: azureDeploy

        env:

          VERBOSE: true

        with:

          repo_token: ${{ steps.app-token.outputs.token }}

          action: "upload"

          app_location: ./_site

          api_location: ./_api

          skip_app_build: true

          skip_api_build: true

          output_location: ""

          deployment_environment: ${{ (needs.Setup.outputs.nkdAgility_AzureSitesEnvironment) }}

          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}

Log: https://github.com/nkdAgility/NKDAgility.com/actions/runs/11594635655/job/32281460532


Verbose logging enabled

Try to validate location at: '/github/workspace/./_site'.

Build timeout not specified, defaulting to 15 minutes

App Directory Location: './_site' was found.

Try to validate location at: '/github/workspace/swa-db-connections'.

Looking for event info

Event info parsed from GitHub event json.

Skipping step to build /github/workspace/./_site with Oryx

Found staticwebapp.config.json file: '_site/staticwebapp.config.json'

Didn't find Oryx manifest file under location: /bin/staticsites/e47c04cd-260e-4fbf-86ed-29ba95663724-swa-oryx/app-manifest/oryx-manifest.toml

Determined default file to be: index.html

Using 'staticwebapp.config.json' file for configuration information, 'routes.json' will be ignored.

Calculating the size of app artifacts: 409548339 B

Try to validate location at: '/github/workspace/./_api'.

Api Directory Location: './_api' was found.

Skipping step to build /github/workspace/./_api with Oryx

Function Runtime Information. OS: windows, Functions Runtime: ~4, dotnetisolated version: 8.0

Found functions.metadata file

Zipping Api Artifacts

Api Zip will be created from directory: /github/workspace/./_api

Api Content Hash: 4ea5b8d7[19](https://github.com/nkdAgility/NKDAgility.com/actions/runs/11594635655/job/32281460532#step:7:20)77aadda19207122664a342

Done Zipping Api Artifacts

Zipping App Artifacts

App Zip will be created from directory: /github/workspace/./_site

Done Zipping App Artifacts

Uploading build artifacts.

Finished Upload. Polling on deployment.

Status: InProgress. Time: 0.1541086(s)

Status: InProgress. Time: 15.3149439(s)

Status: Succeeded. Time: 30.4664566(s)

Deployment Complete :)

Visit your site at: https://yellow-pond-042d21b03-68.westeurope.5.azurestaticapps.net/

Thanks for using Azure Static Web Apps!

Exiting

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
988 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Ryan Hill 28,726 Reputation points Microsoft Employee
    2024-11-01T19:23:22.77+00:00

    Hi @Martin Hinshelwood nkdAgility.com

    I walked through a vanilla HTML and added a C# Function App project for the API. Started with .NET 6 and progress up to .NET 8 just to make sure that wasn't any issues. You really don't need to build your API separately as the Azure/static-web-apps-deploy task will handle that for you.

    There isn't I can see that is overtly wrong with your yaml. From GitHub actions snippet you shared, I don't see any publishing but that could simply outside of what you posted. I noticed you are using preview packages but I don't see being an issue. Just in case, you can try the following to see if that has any positive impact.

    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.23.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.4.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.3.2" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.18.0" />
    

    If you can hit https://your-static-webapp.azurestaticapps.ent/api/<your-endpoint> then more than like it's a portal issue where it's not detecting the function properly. However, you can't hit your API endpoint, then that leads me to believe it's deployment issue where the app code wasn't deployed as expected. In that case, I would start back with a basic Build configuration, see if that works. Then incrementally make the necessary changes as deemed fit.


    EDIT 2024 Nov 18 Glad to see that your issue was resolved by setting api_skip_build to false as part of Azure/static-web-apps-deploy task. My thinking as to why that works, based on https://github.com/Azure/static-web-apps/issues/343, is because you're already building your API and pushing those artifacts to the resource. By telling the underlying platform to skip building it, it will use those built binaries rather than looking for the files to build the output.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.