Many times when we want to deploy something to the cloud, we need it to be a controlled process. We need to know what is going to be deployed, when and how. Also, we need to be able to rollback if something goes wrong. Other times we want a simpler and more stream lined process, the fewer clicks the better. In this post I will show you how to deploy a simple web application to Azure using nothing but Azure Static Apps and Visual Studio Code.
Deploying a web application to Azure Static Apps using Visual Studio Code can be done via the command palette. You're asked to choose Azure account, subscription, resource group and name of the app. The extension will then create a GitHub Action workflow file and deploy the application to Azure. As for how it's being deployed, there's different presets/templates you can use, so if you have an Angular app, or React for example, you can use the corresponding template.
Making deployment even simpler
All the templates that exist for various application types are great, I don't need to remember where the build directory and other artefacts are places etc, the extension keeps track of that for me, I just need to remember what framework I'm using.
However, if I have a simpler app, for example a resume, I want a way to deploy that without being asked a bunch of questions on where's my API, where's my build directory (as I'm not using a SPA framework that needs to build my files before they can be deployed).
Presenting HTML preset, as simple as it gets
Now that we talked about this new preset/template, let's see how we can use it to deploy a simple web application to Azure Static Apps.
1. Open Visual Studio Code.
2. Create a new folder.
3. Create a file called index.html and add the following content:
4. Next, open the command palette and search for `Azure Static Web Apps: Create New Static Web App`.
5. Select subscription, resource group and name of the app.
6. Select the HTML preset from this list presets/templates.
7. Select the location of your source code, in this case it's the current folder.
8. Select the location of your build artifacts, in this case it's the current folder.
Now you should see your app being deployed to Azure Static Apps.
And that's it, now you have a simple web application deployed to Azure Static Apps. You can see the deployed app if you -right-click your app in the Azure Static Apps extension and select `Browse Website`.
Wasn't that simple? I think it was, and I hope you do too. If you want to learn more about Azure Static Apps, check out the documentation Azure Static Apps.