﻿<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>/</id>
	<title />
	<link rel="self" href="/" />
	<rights>2023</rights>
	<updated>2023-04-05T17:13:32Z</updated>
	<entry>
		<id>/posts/azure-swa-getting-started</id>
		<title>Azure Static Web Apps - TBD</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/azure-swa-getting-started" />
		<link rel="enclosure" type="image" href="/images/posts/conny-schneider-xuTJZ7uD7PI-unsplash.jpg" />
		<updated>2023-04-01T00:00:00Z</updated>
		<content>&lt;p&gt;As the demand for fast, scalable, and secure web solutions continues to grow, Azure Static Web Apps have emerged as a powerful and flexible platform for developers. This series is will guide you through the fundamentals of Azure Static Web Apps, deployment process, and look at comprehensive examples. By the end of this journey, you'll be well-equipped to harness the full potential of Azure Static Web Apps and take your web development projects to new heights.&lt;/p&gt;
&lt;h2 id="what-is-azure-static-web-apps"&gt;What is Azure Static Web Apps?&lt;/h2&gt;
&lt;p&gt;Azure Static Web Apps is a cloud-based platform that streamlines the process of building and deploying static web apps. It's a fully managed service that provides a simple, cost-effective, and secure way to host your static web apps. Azure Static Web Apps is built on top of Azure App Service, which means you can take advantage of all the benefits of App Service, including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Scalability&lt;/strong&gt; - Azure Static Web Apps can scale up or down to meet your needs. You can also scale out to multiple instances to handle increased traffic.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Security&lt;/strong&gt; - Azure Static Web Apps is built on top of Azure App Service, which provides a secure and reliable platform for hosting your static web apps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reliability&lt;/strong&gt; - Azure Static Web Apps is built on top of Azure App Service, which provides a secure and reliable platform for hosting your static web apps.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performance&lt;/strong&gt; - Azure Static Web Apps is built on top of Azure App Service, which provides a secure and reliable platform for hosting your static web apps.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="why-use-azure-static-web-apps"&gt;Why use Azure Static Web Apps?&lt;/h2&gt;
&lt;p&gt;For me the biggest reason to use Azure Static Web Apps is the simplicity. With the &lt;a href="https://aka.ms/swa/database-connections"&gt;recent annoucement&lt;/a&gt; that you can automatically generate REST and GraphQL APIs from your static web apps, you can now build a full stack web application without having to worry about the tedious part of writing a backend. This is a huge win for developers who want to focus on building great user experiences.  Now you can easily bundle a multi-tier application including:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Frontend - HTML, CSS, JavaScript, and other static assets&lt;/li&gt;
&lt;li&gt;Backend - Azure Function&lt;/li&gt;
&lt;li&gt;Database - Azure SQL Database, Azure Cosmos DB, or any other database that supports REST or GraphQL APIs&lt;/li&gt;
&lt;li&gt;Authentication - Azure Active Directory, Facebook, Google, Twitter, or any other identity provider that supports OpenID Connect&lt;/li&gt;
&lt;li&gt;CI/CD - GitHub Actions or Azure DevOps Pipelines auto generated and configured for you&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Forces Serverless Patterns&lt;/strong&gt; - Apps that are built for serverless architectures are inherently easier to scalable, secure, and are (in my opinion) more reliable.  This is likely the most challenging point for developers to get their head around.  The idea of not having a server to manage is a foreign concept to many developers.  However, the benefits of serverless architectures are well documented and are becoming more and more popular. If you are interested in learning more about serverless architectures I would recommend checking out &lt;a href="https://learn.microsoft.com/en-us/dotnet/architecture/serverless/"&gt;Serverless apps: Architecture, patterns, and Azure implementation&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of this in your choice of programming language. You can even use your own custom domain name and provided SSL certificate to get your app production ready.&lt;/p&gt;
&lt;h2 id="pre-requisites"&gt;Pre-requisites&lt;/h2&gt;
&lt;p&gt;There are a couple of things you will need to get started.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;An Azure account&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This should be obvious but you will need an Azure account to use Azure Static Web Apps.  If you don't have one you can create one &lt;a href="https://azure.microsoft.com/en-us/free/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A git based repository&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Everything to do with Azure Static Web Apps is done through a git repository hosted in either Github or Azure DevOps.  If you don't have a repository you can create one for free on your platform of choice.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Command line tools&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I used the winget command line tool to install the following tools.  You can find more information about winget &lt;a href="https://docs.microsoft.com/en-us/windows/package-manager/winget/"&gt;here&lt;/a&gt;.&lt;/p&gt;
 &lt;pre class='language-powershell line-numbers' style='white-space:pre-wrap;'&gt;&lt;code&gt;winget install CoreyButler.NVMforWindows
nvm install 16
nvm use 16
winget install -e Git.Git&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All of these are fairly straight forward&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[1] : I recommend using NVMforWindows to manage your node versions.  This will allow you to easily switch between different versions of node.&lt;/li&gt;
&lt;li&gt;[2-3] : Azure CLI and Azure Function Core Tools are both installed using npm.  As of the time of authoring this I ran into issues with later versions of npm with some types of apps so I recommend using npm version 16.&lt;/li&gt;
&lt;li&gt;[1] : Azure CLI that enables you to interact with Azure resources&lt;/li&gt;
&lt;li&gt;[2] : StaticWebApps CLI specifically for interacting with Azure Static Web Apps&lt;/li&gt;
&lt;li&gt;[3] : Azure Function Core Tools that enables you to interact with Azure Functions
&lt;ul&gt;
&lt;li&gt;Note: You should be able to install the Azure Function Core Tools using npm but I had issues with this.  I would recommend using winget to install this.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;[4] : Git CLI that enables you to interact with git repositories (you likely already have this installed but just in case)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;An Application&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Last you will obviously need an application to deploy.  The front end must be able to be statically built along with (optionally) an api that is written to be serverless. In following posts I will be demonstrating how to build simple applications in different languages &amp;amp; frameworks to serve as examples and also demonstrating differences between them.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="my-approach"&gt;My Approach&lt;/h2&gt;
&lt;p&gt;It took me a while to come up with what I felt was the best approach to implementing Azure Static Web Apps.  I wanted to be able to build a simple application that could be deployed to Azure Static Web Apps and then be able to easily add additional functionality to it.  I also wanted to be able to easily switch between different languages and frameworks to demonstrate the differences between them.  And most importantly I wanted the ultimate solution to be intuitive and easy to understand.  A solution that makes sense today but is confusing tomorrow is not a solution.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. use an npm package.json to manage dependencies and scripts
2. use a .env file to manage environment variables
3. use efcore to manage database migrations
4. use Azure B2C for authentication
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I know what you are thinking, &amp;quot;This blog is almost always about C# based solutions and now I need npm?&amp;quot;  I hear you however there are a few reasons why I chose this approach.  First, I wanted a solution that would work regardless of the language or framework you are using.  My first example will be in C# &amp;amp; Blazor however I often am building out front ends in Angular, React, etc. and I wanted a solution that would work for all of them so that I didn't need do more than update the scripts that are being called.  Second, I wanted a solution that is easy to maintain.  The various CLI tools that I want to use are all available as npm packages and from what I could see the npm versions of these commands are available faster than other package managers such as choco or winget.  Third, I wanted the final solution to allow devs to locally run and setup everything they need to run the application as closely to how it would be running in production as possible.  Lastly, I needed the solution to be easy to tweak and customize.  Not every solution is going to be the same, not every project will have the same requirements or conventions. I wanted a solution that would allow developers to easily customize it to fit their needs and not try to force them to accomodate an approach that may not fit perfectly.&lt;/p&gt;
&lt;p&gt;I also wanted this solution to work no matter what environment I was developing in.  I primary use Visual Studio however when I'm working on a front end I often use VS Code because the tooling is better.  For the rest of this series I will be validating everything in VS Code because its more accessible to the majority of developers but I will call out how to do things in Visual Studio as well.&lt;/p&gt;
&lt;h2 id="core-directory-structure-files"&gt;Core Directory Structure &amp;amp; Files&lt;/h2&gt;
&lt;pre&gt;&lt;code class="language-text"&gt;.
├── Api/
│   └── local.settings.json
│   └── ...
├── Db/
│   └── staticwebapp.database.config.json
│   └── ...
├── Web/
│   └── Properties/launchSettings.json (Blazor WSAM)
│   └── ...
├── .env
├── package.json
├── ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Obviously the actual Api/Db/Web code will contain your actual&lt;/p&gt;
&lt;h4 id="the-npm-package.json"&gt;The NPM package.json&lt;/h4&gt;
&lt;pre class='language-json line-numbers' style='white-space:pre-wrap;'&gt;&lt;code&gt;{
  "scripts": {
    "start": "concurrently \"npm run start-api\" \"npm run start-web\" \"npm run start-swa\"",

    "start-api": "cd Api &amp;&amp; func start --csharp",
    "start-web": "cd Web &amp;&amp; dotnet watch run",
    "start-swa": "swa start --data-api-location db",

    "db-reset": "cd Db &amp;&amp; dotnet ef database drop -f &amp;&amp; dotnet ef database update &amp;&amp; dotnet run",
    "db-migrate": "cd Db &amp;&amp; dotnet ef migrations add \"$(date +%s)\"",
    "db-update": "cd Db &amp;&amp; dotnet ef database update",
    "db-drop": "cd Db &amp;&amp; dotnet ef database drop -f"
  },
  "devDependencies": {
    "&amp;#64;azure/static-web-apps-cli": "^1.1.1",
    "azure-functions-core-tools": "^4.0.5095",
    "concurrently": "^8.0.1"
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There's a lot going on here so let's break it down.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[3] : start script - the main entry point for the application.  This will start the api, web, and swa cli tools all at once.  This is accomplished by using the concurrently npm package to start 3 other scripts in parallel.&lt;/li&gt;
&lt;li&gt;[5-7] : start-* scripts - these scripts are used to start the various parts of the application.  The important part about this approach
&lt;ul&gt;
&lt;li&gt;start-api script will start the api using the Azure Function Core Tools.  In my case I am using C# however this approach can accomodate other languages simply by updating the argument to the func command.&lt;/li&gt;
&lt;li&gt;start-web script will start the web application using dotnet watch.  This example is using Blazor WebAssembly however this approach can accomodate other frameworks simply by updating the command that is being run.&lt;/li&gt;
&lt;li&gt;start-swa script will start the Azure Static Web Apps (SWA) CLI w/ the --data-api-location parameter to tell it where the database definition is located.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;[9-12] : db-* scripts - these scripts are used to manage the database using efcore
&lt;ul&gt;
&lt;li&gt;db-reset script will drop the database, run all migrations, and then seed the database.&lt;/li&gt;
&lt;li&gt;The db-migrate script will create a new migration using the current timestamp as the name.  A helper script for devs to be able to build out migrations without needing to look up the efcore commands or the standard naming convention for the current project.&lt;/li&gt;
&lt;li&gt;The db-update script will ensure the target Database is up to date.&lt;/li&gt;
&lt;li&gt;The db-drop script will drop the database.  This will be important when we are automating creating a database per staging environment.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;[15-17] : devDependencies - the various npm packages that are used to manage the application.  These are all installed using npm install.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="the.env-file"&gt;The .env file&lt;/h3&gt;
&lt;p&gt;Another key consideration in this approach was where environment specific configurations were going to pulled from and to streamline the process as much as possible for the developers without needing them to read a long setup doc to set everything up.  I adopted using an .env file because support for it was already built into the swa cli and it was relatively easy to use that for other parts of the application as well.  In my simple case I ended up with a very simple .env file that looks like this:&lt;/p&gt;
&lt;pre class='language-json line-numbers' style='white-space:pre-wrap;'&gt;&lt;code&gt;DB_CONNECTION_STRING=[REDACTED]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The DB_CONNECTION_STRING is used by the data-api to auto-generate Rest &amp;amp; GraphQL endpoints for the application to use.  And I was able to easily use this with efcore migrations and the api.&lt;/p&gt;
&lt;p&gt;The biggest advantage of this is that the .env file is ONLY used in development.  When the application is deployed and runnin in Azure the environment variables are pulled from the configuration settings in Azure.&lt;/p&gt;
&lt;h3 id="the-local.settings.json-file-and-launchsettings.json-file"&gt;The local.settings.json file and launchSettings.json file&lt;/h3&gt;
&lt;p&gt;The npm scripts are all expecting the Api and Web projects to run locally on a certain&lt;/p&gt;
&lt;h2 id="tradeoffs"&gt;Tradeoffs&lt;/h2&gt;
&lt;p&gt;Like any approach there are tradeoffs.  The biggest tradeoff with this approach is that using &lt;code&gt;npm start&lt;/code&gt; to start the application will start 3 processes.  This is not a huge deal but it does mean you need to understand that when you are launching the application you need to kill all 3 processes when you are done.  That is one of the reasons why I broke the start script into 3 parts so that if you want you can start them in separate terminal windows, or use VS Code / Visual Studio to start pieces that you want to attach debuggers to.&lt;/p&gt;
&lt;p&gt;Not a huge deal but something to be aware of.&lt;/p&gt;
&lt;h2 id="whats-next"&gt;What's Next&lt;/h2&gt;
&lt;p&gt;Depending on yours needs you can take a look at other posts in this series to understand how to set those up to work with this approach.  What types of front ends are you developing with? What do you use for auth? Leave a comment below and let me know.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="xref:azure-swa-api-csharp"&gt;Api - C#&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="xref:azure-swa-db-efcore"&gt;Db - EF Core&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="xref:azure-swa-db-rest"&gt;Db - Rest APIs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="xref:azure-swa-db-graphql"&gt;Db - GraphQL APIs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="xref:azure-swa-db-auth"&gt;Db - Integrated Auth&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="xref:azure-swa-web-blazor"&gt;Web - Blazor WebAssembly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="xref:azure-swa-web-react"&gt;Web - React&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
		<summary>&lt;p&gt;As the demand for fast, scalable, and secure web solutions continues to grow, Azure Static Web Apps have emerged as a powerful and flexible platform for developers. This series is will guide you through the fundamentals of Azure Static Web Apps, deployment process, and look at comprehensive examples. By the end of this journey, you'll be well-equipped to harness the full potential of Azure Static Web Apps and take your web development projects to new heights.&lt;/p&gt;</summary>
	</entry>
	<entry>
		<id>/posts/azure-swa-db-graphql</id>
		<title>Azure Static Web Apps - Blazor WebAssembly</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/azure-swa-db-graphql" />
		<link rel="enclosure" type="image" href="/images/posts/pankaj-patel-u2Ru4QBXA5Q-unsplash.jpg" />
		<updated>2023-03-02T00:00:00Z</updated>
		<content>&lt;p&gt;Comming Soon&lt;/p&gt;
</content>
		<summary>&lt;p&gt;Comming Soon&lt;/p&gt;</summary>
	</entry>
	<entry>
		<id>/posts/azure-swa-db-rest</id>
		<title>Azure Static Web Apps - Blazor WebAssembly</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/azure-swa-db-rest" />
		<link rel="enclosure" type="image" href="/images/posts/pankaj-patel-u2Ru4QBXA5Q-unsplash.jpg" />
		<updated>2023-03-02T00:00:00Z</updated>
		<content>&lt;p&gt;Comming Soon&lt;/p&gt;
</content>
		<summary>&lt;p&gt;Comming Soon&lt;/p&gt;</summary>
	</entry>
	<entry>
		<id>/posts/azure-swa-web-react</id>
		<title>Azure Static Web Apps - Blazor WebAssembly</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/azure-swa-web-react" />
		<link rel="enclosure" type="image" href="/images/posts/pankaj-patel-u2Ru4QBXA5Q-unsplash.jpg" />
		<updated>2023-03-02T00:00:00Z</updated>
		<content>&lt;p&gt;Comming Soon&lt;/p&gt;
</content>
		<summary>&lt;p&gt;Comming Soon&lt;/p&gt;</summary>
	</entry>
	<entry>
		<id>/posts/azure-swa-api-csharp</id>
		<title>Azure Static Web Apps - Blazor WebAssembly</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/azure-swa-api-csharp" />
		<link rel="enclosure" type="image" href="/images/posts/pankaj-patel-u2Ru4QBXA5Q-unsplash.jpg" />
		<updated>2023-03-02T00:00:00Z</updated>
		<content>&lt;p&gt;Comming Soon&lt;/p&gt;
</content>
		<summary>&lt;p&gt;Comming Soon&lt;/p&gt;</summary>
	</entry>
	<entry>
		<id>/posts/azure-swa-web-blazor</id>
		<title>Azure Static Web Apps - Blazor WebAssembly</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/azure-swa-web-blazor" />
		<link rel="enclosure" type="image" href="/images/posts/pankaj-patel-u2Ru4QBXA5Q-unsplash.jpg" />
		<updated>2023-03-02T00:00:00Z</updated>
		<content>&lt;h1 id="azure-static-web-apps-blazor-webassembly"&gt;Azure Static Web Apps - Blazor WebAssembly&lt;/h1&gt;
&lt;p&gt;In the (Getting Started)[xref:azure-swa-getting-started] post, we discussed the basics of Azure Static Web Apps and how to get started with a simple static web app. In this post, we will take a look at an example of a Blazor WebAssembly app and how to deploy it to Azure Static Web Apps.&lt;/p&gt;
&lt;h2 id="create-a-new-blazor-webassembly-app"&gt;Create a new Blazor WebAssembly app&lt;/h2&gt;
&lt;p&gt;To get started, we will create a new Blazor WebAssembly app using the .NET CLI. Open a terminal and run the following commands:&lt;/p&gt;
&lt;pre class='language-powershell line-numbers' style='white-space:pre-wrap;'&gt;&lt;code&gt;winget install 
npm install --save-dev &amp;#64;azure/static-web-apps-cli
dotnet new blazorwasm -o App
cd App
dotnet add package Microsoft.AspNetCore.Components.WebAssembly.StaticWebAssets
cd ..
func init MyProject.Api --dotnet
Rename-Item MyProject.Api Api
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;Special Thanks to &lt;a href="https://unsplash.com/&amp;#64;pankajpatel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"&gt;Pankaj Patel&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/u2Ru4QBXA5Q?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt; for the photo used for this post&lt;/span&gt;&lt;/p&gt;
</content>
		<summary>&lt;p&gt;In the (Getting Started)[xref:azure-swa-getting-started] post, we discussed the basics of Azure Static Web Apps and how to get started with a simple static web app. In this post, we will take a look at an example of a Blazor WebAssembly app and how to deploy it to Azure Static Web Apps.&lt;/p&gt;</summary>
	</entry>
	<entry>
		<id>/posts/azure-swa-db-efcore</id>
		<title>Azure Static Web Apps - Blazor WebAssembly</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/azure-swa-db-efcore" />
		<link rel="enclosure" type="image" href="/images/posts/pankaj-patel-u2Ru4QBXA5Q-unsplash.jpg" />
		<updated>2023-03-02T00:00:00Z</updated>
		<content>&lt;p&gt;Comming Soon&lt;/p&gt;
</content>
		<summary>&lt;p&gt;Comming Soon&lt;/p&gt;</summary>
	</entry>
	<entry>
		<id>/posts/azure-swa-db-auth</id>
		<title>Azure Static Web Apps - Blazor WebAssembly</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/azure-swa-db-auth" />
		<link rel="enclosure" type="image" href="/images/posts/pankaj-patel-u2Ru4QBXA5Q-unsplash.jpg" />
		<updated>2023-03-02T00:00:00Z</updated>
		<content>&lt;p&gt;Comming Soon&lt;/p&gt;
</content>
		<summary>&lt;p&gt;Comming Soon&lt;/p&gt;</summary>
	</entry>
	<entry>
		<id>/posts/statiq-deploy-to-static-web-app</id>
		<title>Deploying Statiq to Azure Static Web App</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/statiq-deploy-to-static-web-app" />
		<link rel="enclosure" type="image" href="/images/posts/antonino-visalli-uZsDcxog6EM-unsplash.jpg" />
		<updated>2020-12-01T00:00:00Z</updated>
		<content>&lt;p&gt;&lt;a href="https://statiq.dev/"&gt;Statiq&lt;/a&gt; is a &lt;a href="https://en.wikipedia.org/wiki/Web_template_system#Static_site_generators"&gt;static content generator&lt;/a&gt; written in C# that is used to generate the site you are reading right now.  It is an incredibly robust and feature full project, Below is a series of steps that you can walk through to create your own blog similar to this one.&lt;/p&gt;
&lt;p&gt;The source for the app that generates this site is open source at &lt;a href="https://github.com/e13tech/blog"&gt;https://github.com/e13tech/blog&lt;/a&gt;.  Feel free to browse the source and get inspiration for your own project.&lt;/p&gt;
&lt;h3 id="deploy-to-azure-static-web-app-using-github-actions"&gt;Deploy to Azure Static Web App using Github Actions&lt;/h3&gt;
&lt;p&gt;&lt;a href="https://azure.microsoft.com/en-us/services/app-service/static/"&gt;Static Web Apps&lt;/a&gt; is an offering in Azure that is currently in preview that streamlines the deployment of applications from GitHub.  It has a few limitations in preview but being able to quickly setup&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create new Static Web App resource in the Azure Portal
&lt;a href="/images/posts/azure-swa.png"&gt;&lt;img src="/images/posts/azure-swa.png" alt="New SWA" title="New SWA"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Note this is still in preview so it may not be ideal for widespread production use however while it is in preview having a platform to host a static site with a custom domain over https for free is an incredible value.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter the details to your github repository
&lt;a href="/images/posts/azure-swa-details.png"&gt;&lt;img src="/images/posts/azure-swa-details.png" alt="New SWA" title="New SWA"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The important details here are using the &lt;code&gt;Custom&lt;/code&gt; Build Preset with the App location of &lt;code&gt;output&lt;/code&gt;. For Statiq there is no need for an Api or App artifact location so clear those out. However being able to tie the deployment of an Api as an Azure Function opens up some incredible opportunities for expanding to a more dynamic solution.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wait for the resource to be created
&lt;br&gt;&lt;br&gt;
I don't normally document wait steps but this one is important.  As part of the resource creation a new GitHub workflow will be created in the branch specific at creation time complete with the secrets to access the newly created resource.  Once you have verified that the GitHub workflow has been created successfully then we can modify it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update the auto generated workflow yml to run the Statiq console app and produce the output that will actually get published to Azure. Note: do not attempt to rename the file because the created azure resource refers to it for some of it's functionality.&lt;/p&gt;
 &lt;pre class="language-yaml line-numbers" style="white-space:pre-wrap;"&gt;&lt;code&gt;name: Azure Static Web Apps CI/CD

on:
  pull_request:
  types: [opened, synchronize, reopened, closed]
  branches: [main]

jobs:
  build:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' &amp;amp;&amp;amp; github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build And Update Pull Request

    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 5.0.100
    - run: dotnet restore
    - run: dotnet build --configuration Release --no-restore
    - run: dotnet run --output output
    - name: Build And Deploy
      id: builddeploy
      uses: Azure/static-web-apps-deploy@v0.0.1-preview
      with:
        azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_... }}
        repo_token: ${{ secrets.GITHUB_TOKEN }}
        action: "upload"
        app_location: "output" # App source code path
        api_location: "" # Api source code path - optional
        output_location: "" # Built app content directory - optional

close_pull_request_job:
  if: github.event_name == 'pull_request' &amp;amp;&amp;amp; github.event.action == 'closed'
  runs-on: ubuntu-latest
  name: Close Pull Request Job
  steps:
    - name: Close Pull Request
      id: closepullrequest
      uses: Azure/static-web-apps-deploy@v0.0.1-preview
      with:
        azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_... }}
        action: "close"&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a large file but my changes can be broken down into a few segments&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[1] : Keep the workflow name the auto-generated one because there is a link w/in Azure that is looking specifically for that&lt;/li&gt;
&lt;li&gt;[3-6] : Setup a trigger on pull requests going into the main branch. My preference is to have feature branches for my blog articles and to create a PR for each into main branch while I work on them.&lt;/li&gt;
&lt;li&gt;[14-21] : The series of standard steps that prepares a .NET 5 environment
&lt;ul&gt;
&lt;li&gt;[21] : Run the console app directing the generated content to an &lt;code&gt;output&lt;/code&gt; directory&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;[22-31] : The original step that was generated by Azure to do the actual publish
&lt;ul&gt;
&lt;li&gt;[29] : app_location needs to match the same path that was used on [24], in this example &lt;code&gt;output&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;[30,31] : api_location and output_location are not required for this Statiq example but ensure they are left blank&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;[33-43] : This job triggers on the closure of a pull request to clean up the staging url that can be used to preview the output of a branch that is still in development&lt;/li&gt;
&lt;li&gt;[26,42] : These lines point to the secret that is generated in the github repository, this name will be uniquely generated and set to your application&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="recap"&gt;Recap&lt;/h3&gt;
&lt;p&gt;Now even though it was not defined as a template originally we are able streamline the process of developing content using Statiq and having it automatically deploy to  Azure.  The best part of this workflow is that I can create a branch for each topic that I am beginning blogs on and as long as there is an open pull request attached to the branch then the github action will create a unique url.  This allows you to share that url with anyone to review the actual generated content exactly as it would in production, and once the PR is merged and accepted no additional steps are required in order to publish to production.&lt;/p&gt;
&lt;p&gt;This is convenient for a personal blog like this so I can loop in colleagues for help proofing a post before it's done.  You can probably also see how beneficial this could be for a corporate blog or anywhere that content needs to be reviewed or approved.  Setting up a CI/CD flow is usually more complex involving setting up environments, approval processes, etc.  Microsoft has done a fantastic job creating this offering and especially while it's in preview you'd be hard pressed to find a more appealing option while it is free to use.&lt;/p&gt;
&lt;p&gt;What kind of  projects will you setup using this workflow? What adjustments will you make to improve it? Share with others in the comments below!&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Special Thanks to &lt;a href="https://unsplash.com/@ninovisalli?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Antonino Visalli&lt;/a&gt; on &lt;a href="https://unsplash.com/t/technology?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;for the photo that was used in this post&lt;/span&gt;&lt;/p&gt;
</content>
		<summary>&lt;p&gt;&lt;a href="https://statiq.dev/"&gt;Statiq&lt;/a&gt; is a &lt;a href="https://en.wikipedia.org/wiki/Web_template_system#Static_site_generators"&gt;static content generator&lt;/a&gt; written in C# that is used to generate the site you are reading right now.  It is an incredibly robust and feature full project, Below is a series of steps that you can walk through to create your own blog similar to this one.&lt;/p&gt;</summary>
	</entry>
	<entry>
		<id>/posts/statiq-blog-getting-started</id>
		<title>Blog using Statiq - Getting Started</title>
		<author>
			<name>JJ Bussert</name>
		</author>
		<link href="/posts/statiq-blog-getting-started" />
		<link rel="enclosure" type="image" href="/images/philipp-katzenberger-iIJrUoeRoCQ-unsplash.jpg" />
		<updated>2020-11-01T00:00:00Z</updated>
		<content>&lt;p&gt;&lt;a href="https://statiq.dev/"&gt;Statiq&lt;/a&gt; is a &lt;a href="https://en.wikipedia.org/wiki/Web_template_system#Static_site_generators"&gt;static content generator&lt;/a&gt; written in c# that is used to generate the site you are reading right now.  It is an incredibly robust and feature full project, Below is a series of steps that you can walk through to create your own blog similar to this one.&lt;/p&gt;
&lt;p&gt;The source for the app that generates this site is open source at &lt;a href="https://github.com/e13tech/blog"&gt;https://github.com/e13tech/blog&lt;/a&gt;.  Feel free to browse the source and get inspiration for your own project.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a new .NET console app and add the Statiq.Web Package&lt;/p&gt;
 &lt;pre class='language-powershell line-numbers' style='white-space:pre-wrap;'&gt;&lt;code&gt;dotnet new console --name AwesomeBlog
cd AwesomeBlog
dotnet add package Statiq.Web --version 1.0.0-beta.13
md input
md theme\input&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Most of this is fairly intuitive but in case you need some more details&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[1] : Create a .NET console app that will be the generator for your site&lt;/li&gt;
&lt;li&gt;[2] : Navigate into the directory for your new console app&lt;/li&gt;
&lt;li&gt;[3] : Add the Statiq.Web nuget package, at the time of writing this Statiq is still prerelease so specify the version&lt;/li&gt;
&lt;li&gt;[4] : Create the input directory that will host&lt;/li&gt;
&lt;li&gt;[5] : Create the theme input directory that will contain the layout and other site assets&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a bootstrapper Program.cs&lt;/p&gt;
 &lt;pre class='language-csharp line-numbers match-braces' style='white-space:pre-wrap;'&gt;&lt;code&gt;using System.Threading.Tasks;
using Statiq.App;
using Statiq.Web;

namespace Your.AwesomeBlog
{
  public class Program
  {
    public static async Task&lt;int&gt; Main(string[] args) =&gt;
      await Bootstrapper
        .Factory
        .CreateWeb(args)
        .RunAsync();
  }
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A very straight forward Program.cs, notable lines:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[2] : The core Statiq framework namespace with the original Bootstrapper.Factory comes from&lt;/li&gt;
&lt;li&gt;[3] : The Statiq Web namespace which provides the .CreateWeb(..)&lt;/li&gt;
&lt;li&gt;[9-13] : Have the Main(string[]) method await the call to the Statiq &lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a new &lt;code&gt;index.md&lt;/code&gt; file within the &lt;code&gt;input&lt;/code&gt; directory with the following content&lt;/p&gt;
 &lt;pre class='language-markdown line-numbers' style='white-space:pre-wrap;'&gt;&lt;code&gt;Title: My First Statiq page
 ---
 # Hello World!

 Hello from my first Statiq page.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There are countless great sources online explaining how &lt;a href="https://statiq.dev/framework/content/template-languages#markdown"&gt;Markdown&lt;/a&gt; works including the official Statiq website.  In a follow-up post I will go through an example of how I am utilizing this input files.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Launch the built-in previewer from a &lt;a href="xref:windows-terminal-getting-started"&gt;terminal window&lt;/a&gt;&lt;/p&gt;
 &lt;pre class='language-powershell line-numbers' style='white-space:pre-wrap;'&gt;&lt;code&gt;dotnet run -- preview&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If all went well Statiq will display a bunch of diagnostic information and then host your new site at https://localhost:5080 with livereload meaning that you can edit your site content in your favorite editor such as VS Code and the browser will reload to display your changes as you save.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Most of these steps here are borrowed directly from the &lt;a href="https://statiq.dev/web/#quick-start"&gt;Statiq Quick Start&lt;/a&gt; and adjusted for my content.  Combining &lt;a href="https://github.com/statiqdev/CleanBlog"&gt;Clean Blog Template&lt;/a&gt; with a responsive web template such as one from as a starting point will get you most of the way towards having a blog of your own, lets look at some of the modifications I made beyond this.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://statiq.dev/web/"&gt;Statiq Web&lt;/a&gt; is built on top of &lt;a href="https://statiq.dev/framework"&gt;Statiq Framework&lt;/a&gt; and this series covers a small fraction of the functionality of this fantastic project.  So far I am very happy with this platform and am anticipating the release of &lt;a href="https://statiq.dev/docs/"&gt;Statiq Docs&lt;/a&gt; which is built on top of the Statiq Web with a focus on generating .NET API documentation.&lt;/p&gt;
&lt;p&gt;What static content generator have you used? Do you have a blog of your own that's statically generated? Share your experiences in the comments below.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Special Thanks to &lt;a href="https://unsplash.com/&amp;#64;fantasyflip?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Philipp Katzenberger&lt;/a&gt; on &lt;a href="https://unsplash.com/?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt; for the photo used for this post&lt;/span&gt;&lt;/p&gt;
</content>
		<summary>&lt;p&gt;&lt;a href="https://statiq.dev/"&gt;Statiq&lt;/a&gt; is a &lt;a href="https://en.wikipedia.org/wiki/Web_template_system#Static_site_generators"&gt;static content generator&lt;/a&gt; written in c# that is used to generate the site you are reading right now.  It is an incredibly robust and feature full project, Below is a series of steps that you can walk through to create your own blog similar to this one.&lt;/p&gt;</summary>
	</entry>
</feed>