Skip to content

Possibility to run Data API builder solution within Static Web App.

License

Notifications You must be signed in to change notification settings

wrutkowski-xebia/research-data-api-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DAB

Updates

  • March 2024 1: checking DAB version 0.10.*

Research of Data API builder

Check possibilities that Data API builder has to offer.

It it possible to run API builder solution within Static Web App?

Yes / No ?

  • For deployed together with and on Static Web App, I would say NO for production use because of: cold start, Application Insights problems and at the moment of writing there are 322 open issues on MS DAB GitHub project.

How about configuration Static Web App + DAB Docker Container?

  • Big picture on diagram: SWA and DAB as container
  • Starting from repository there are two GithHub actions:
    • One: deploy Blazor app to SWA
    • Second: build image from Dockerfile, put it in registry and publish on Azure Container Apps

Azure Resources needed for this kind of solution

  • Application Insights
  • Static Web App
  • SQL server
  • SQL database
  • Optional (DAB in container):
    • Container App
    • Container Apps Environment

Azure Static Web Apps + Data API builder

Links

Some maybe not obvious/common topics

Issues

More about using containers for DAB

  • No one way do do it right.
  • Azure Container Instances - lack of later update capabilities of already running container (ex. same IP address not guarantee). Seems that later maintenance could be problematic when deploying this way. Instances service looks like more to be used as one-off scenario.
  • Azure Container Apps or App Service should be better choice for long term use.
  • Azure Container Apps offer to much, for this scenario needs, and on the other hand Azure Container Instances don't have everything needed.
  • Maybe even better would be App Service.
  • Many deployment options of image.
  • Application Insights seems working when running from container.

From Dockerfile to Azure Container Apps - some not obvious settings

  • Deploy GitHub Action: appSourcePath: ${{ github.workspace }} as absolute path, dockerfilePath, buildArguments as relative paths
  • Azure Container Apps: Ingress: Target port 5000
  • Connection string settings/format issues, this was tested and works: Data Source=server,1433;Initial Catalog=db;User ID=user;Password=password also can try to generate one from "Service Connector" (auto crate new entry in secrets)

Secrets with Visual Studio 2022 + Containers + Azure Cloud

type VS Docker Azure Container Apps
environment don't support swarm in swarm mode environment secrets
file don't support swarm in swarm mode secrets mount as volume
CLI docker secret don't support swarm in swarm mode n/a? not swarm mode?

Data API Builder uses @env("env_name") in configuration files and ex. connection string seems to be stored as environment variable. Where in Azure there seems no problem to store it as a secret, there could be issue on local development, because Docker needs swarm mode and VS out of the box support only Docker Compose. For local dev seems storing connection string in local env seems not best but solution. Seems in Azure build-in solution is working like equivalent for /run/secrets/<name> in pure docker.

Authentication, Authorization (JWT)

  • "Default" Azure App registration + Enterprise Application configuration for SWA + API
  • Adding to request: JWT token, header X-MS-API-ROLE=role (seems token alone is not working)

Local DEV: General Problems

  • Port 5000 for DAB can't be changed.
  • Blazor WASM can't be debug with containers?
    • #37565
    • "Unsupported scenarios: Debug in non-local scenarios" MS Docs

Local DEV Concept: Blazor WASM + SWA CLI Docker

  • VS don't support Swarm mode out of the box. This mode, would be nice here, mostly for using Secrets feature, not because of complexity of application etc.
  • Visual Studio 2022 Docker - MS Docs
  • Adding Docker to Blazor isn't supported thru project create wizard. It's need to be added later similar like for React one.
  • Dockerfile and docker-compose needs to customized as in this repo.
  • Environment variable needs to be added: DATABASE_CONNECTION_STRING
  • If DB is hosted on Azure check firewall settings.

Local Dev Concept Problems: Blazor WASM + SWA CLI Docker

Seems making VS Docker Compose "hit F5 and debug/run" it's not so easy to make local dev easier, even its brings more challenges. There are some VS Docker Tools and SWA CLI issues around debugging and even executing app in container.


Local Dev Concept: Blazor WASM + custom Dockerfile

Prepare specific Dockerfile with using ex. Microsoft ASP.Net Core docker images as a base for building, publishing and etc.

Local Dev Concept Problems: Blazor WASM + custom Dockerfile

Footnotes

  1. Local setup: Windows 10, Visual Studio 2022 17.9.6, Docker Desktop 4.28.0, WSL, Ubuntu 20.04 (WSL) (there were some issues with 22.04), .Net 8.0

About

Possibility to run Data API builder solution within Static Web App.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published