- Регистрация
- 9 Май 2015
- Сообщения
- 1,483
- Баллы
- 155


After learning how to authenticate with Azure services and how to publish our backend, today we’ll focus on the frontend.
If you’re building a Single Page Application (SPA) with frameworks like React, Angular, or Vue, you’ll see that publishing your app on Azure is simpler and cheaper than you might think.

When publishing SPAs in Azure, you might think about using App Service (the same one we used for the backend).
But here’s the trick: SPAs don’t need a full backend hosting environment.
Instead, the most efficient and cost-effective way is to use Azure Storage Static Website Hosting.
Why?





If you’re using React, Angular, or another SPA framework, the first step is to build the production version of your app.
For example, in Angular:
ng build --configuration production
In React:
npm run build
This will generate a folder (usually called dist or build) with all the compiled static files (HTML, CSS, JS, and assets).

In Azure Portal:
Search for Storage Account.
Create a new account (standard performance is usually enough).
Go to the Static Website menu (inside the storage account).
Enable it and configure the index document (e.g., index.html) and error document (e.g., index.html as well, if you’re using SPA routing).
This will generate a public URL for your website, something like:
https://<your-storage-account>.zxx.web.core.windows.net

There are different ways to upload your SPA build to the storage account:
Azure Portal: upload files directly in the browser.
Azure Storage Explorer (a free Microsoft tool).
Azure CLI:
az storage blob upload-batch \
--account-name <your-storage-account> \
--destination '$web' \
--source ./build

If your users are spread across different regions, you can easily integrate a CDN to ensure your frontend loads faster worldwide.
In the storage account:
- Go to Front Door and CDN.
- Create a new CDN profile.
- Link it to your static website endpoint.
That’s it — now your SPA is globally distributed!


Publishing your frontend in Azure doesn’t have to be complicated or expensive.
With just a Storage Account, you get a secure, highly available, and low-cost hosting solution for your SPAs.


Источник: