2. Static app vs Web App
• No resolve
process, just
• HTML
• CSS
• JavaScript
@chris_noring
• Dynamic pages
• Resolve with call to backend
• Produces:
• HTML
• CSS
• JavaScript
• Static pages
Web AppStatic App
3. How do we create ?
• SPA frameworks like
• React
• Angular
• Vue
• Svelte
@chris_noring
Web app
• Static site generators like
• VuePress
• Gatsby
• Scully
Static app
4. The jamstack
It’s not about technologies but - Prerendering files, serve from
CDN
WHY & WHAT YOU GET
- better performance,
- higher security,
- lower cost of scaling,
- better developer experience
YOU CAN ENHANCE THEM
- Pre-rendered sites can be enhanced with JavaScript
and the growing capabilities of browsers and services
available via APIs
https://jamstack.org/
@chris_noring
5. Traditional apps vs JamStack
Frontend
Backend
DB
Page load when:
1. Page talks to backend
2. Backend talks to DB
3. Rendering
Static
app
API
API
Frontend
Pre rendering
DB
YAML
JSON Markup
JAMSTACK
1.
2.
@chris_noring
Static
app
Static
appCDN
6. Deploying a Jamstack
• The parts
• The static app
• The API ?
• Things to consider
• Fallback routes
• Auth?
• Prep to deploy (build step/s)
@chris_noring
7. Azure Static Web Apps service
• Web hosting for static content like HTML, CSS, JavaScript, and images.
• Integrated API support provided by Azure Functions.
• First-party GitHub integration where repository changes trigger builds and deployments.
• Globally distributed static content, putting content closer to your users.
• Free SSL certificates, which are automatically renewed.
• Custom domains* to provide branded customizations to your app.
• Seamless security model with a reverse-proxy when calling APIs, which requires no CORS configuration.
• Authentication provider integrations with Azure Active Directory, Facebook, Google, GitHub, and Twitter.
• Customizable authorization role definition and assignments.
• Back-end routing rules enabling full control over the content and routes you serve.
• Generated staging versions powered by pull requests enabling preview versions of your site before publishing.
@chris_noring
12. Auth,
inivitation
• Generate
• Select provider
• Add username or email address
• Select domain (the custom domain)
• Add roles, admin, user etc (comma
separated)
• Enter invitation validity in hours
• Generate a link
• Invite
• Send generated link
• Login
• Recipient is prompted to login with their login
of chosen provider type
@chris_noring
13.
14. Auth, how to implement
<a href="/.auth/login/github">Login</a>
“routes”: [{
"route": "/login",
"serve": "/.auth/login/github"
}]
routes.json
Send user to login page
<a href="/.auth/logout">Log out</a> Have user logout with a link like this
post_login_redirect_uri= <send user here>
Set this query parameter if you want to send user
To a specific route after login
18. Summary
• Static apps, just HTML, CSS, JS, secure, small and fast to load
• Web Apps, has backend, resolves when it’s requested, can never
be as fast as above
• Static Web Apps,
• can help you deploy both types of app
• Supports Azure Function as API
• Supports Auth with AAD, Azure Active Directory and social logins like
Twitter, Facebook, GitHub et al
@chris_noring
19. Learn more
• Aka.ms/swadocs , Overview page
• Getting blazor to work on Static Web Apps
https://timheuer.com/blog/category/blazor
• LEARN module, Gatsby + SWA, https://docs.microsoft.com/en-
us/learn/modules/create-deploy-static-webapp-gatsby-app-service/
• LEARN module, SPA deploy (Angular, React, Vue, Svelte),
https://docs.microsoft.com/en-us/learn/modules/publish-app-service-static-
web-app-api
• Securing your app, https://docs.microsoft.com/en-gb/azure/static-web-
apps/authentication-authorization AAD + Social login
@chris_noring
Hinweis der Redaktion
We have static pages in both cases but Web App is a more complicated thing with
A resolve process
A backend
Static app, can also use a Backend, like an API, but at build time, not resolved Just in Time
The idea is to talk to APIs and via static content, render HTML pages that don’t change
Fast and secure sites and apps delivered by pre-rendering files and serving them directly from a CDN, removing the requirement to manage or run web servers.
WHAT YOU GET
better performance, - pre rendered
higher security, - there’s no backend
lower cost of scaling, - using CDN
better developer experience
YOU CAN ENHANCE THEM
Pre-rendered sites can be enhanced with JavaScript and the growing capabilities of browsers and services available via APIs
What does this look like in practice?
The traditional Web App serves pages by
Talking to a backend
Fetch data
Render a finished page
The JamStack, creates everything at build time
It also scales by placing copies of the static pages on various Servers, part of a CDN, Content delivery network to ensure scaling.
The static app
Deploying JamStack is easy, it’s just static files, you an deploy them anywhere like:
GitHub
A Web hotel
Cloud storage like Blob storage
The API
If the API is a separate thing then you don’t need to worry, but IF the API is something that goes with the site then you need to consider how:
Serverless, App Service
Routing
SPA apps needs to think about fallback routes, because of how the routing work
Auth
Auth, we might all kinds of solutions here like Identity Server or some kind of OAuth like JWT based
Azure static web app service enables us to easy deploy our web apps and static apps to the Cloud in minutes.
1. Deploy static sites like Gatsby Hugo, VuePress
2. Deploy web apps built with Next, Nuxt,
3. Build and deploy Modern JavaScript Apps built with Angular, React, Vue, Svelte
The idea here is to show how we can take a React application and easily deploy it
Go to portal, enter static web apps
Project details, fill in
Subscription
Resource group
Static Web App details
Name
Region
SKU
Sign in with GitHub
Enter source control details
Organization
Repository
Branch
Click Next > Build
Build
App location, where’s the app root or subfolder
API location, usually API
App artifact location, what directory does it build to <app location>/build for example
Review & Create, select Create
Go to resource
Remember that Azure portal page?
URL is where we find our app
Workflow file, this is the YAML file that contains instructions for how to build and deploy your app
Let’s take a closer look on the Workflow file
This workflow file was added to our repo, with it we can
When it’s triggered, Change when it’s triggered
Change our selections, Change things like app_location, api_location, app_artifact_location
We can do all sorts of adjustment it’s our YAML
build file. E.g make it work for Blazor for example.
Build an API
Create a function app
Configure local.dev.settings + Cors
React App
Configure proxy
Call API locally
Deploy
Just add changes to Git
Push code
Go to GitHub
View page
Settings > Role Management > Invite
Here’s how you can set things up in your app
Login link
Add entry in routes.json so we know what provider is being used
Logout link
Redirect param on login link, to ensure they end where you want
How do we know if user is logged in?
We check, via this API call, /.auth/me
We can also check user roles that way
If you are in the API and wants to know who the user is, what authorization they have
Specify the route and the role/s it should allow for
On the right, a more real example of how an app should be configured
authenticated, built-in
administrator
404
login, logout routes