Azure Static Website Deployment Slots

Posted on by admin
-->Azure

You can serve static content (HTML, CSS, JavaScript, and image files) directly from a storage container named $web. Hosting your content in Azure Storage enables you to use serverless architectures that include Azure Functions and other Platform as a service (PaaS) services. Azure Storage static website hosting is a great option in cases where you don't require a web server to render content.

Azure Deployment Slots is a feature that allows Web Apps, API Apps and Function Apps to run different instances of their application at the same time (known as slots). Slots are exposed via a publicly available endpoint.

App Service Static Web Apps is a great alternative to Azure Storage static website hosting and is also appropriate in cases where you don't require a web server to render content. App Service Static Web Apps provide you with a fully managed continuous integration and continuous delivery (CI/CD) workflow from GitHub source to global deployment.

If you need a web server to render content, you can use Azure App Service.

Note

The features described in this article are now available to accounts that have a hierarchical namespace. To review limitations, see the Blob storage features available in Azure Data Lake Storage Gen2 article.

Note

Make sure to create a general-purpose v2 Standard storage account . Static websites aren't available in any other type of storage account.

Setting up a static website

AFAIK, we could access it after enabling MSI for deployment slot, you could check my test steps. 1.I have two slots, then I enable MSI of both of them in the portal. You could check them in the Azure Active Directory - Enterprise applications in the portal, refer to the screenshot. Note: You should specify the Application Type option with All Applications when you are searching. After the slot is created, if you click on the slot, you will be taken to another Web App. So what happens behind the scenes is Azure does create another Web App with some more sugar on top of it so that it can be classified as a deployment slot. You can use this slot to push code to this the same way you have pushed to the original Web App.

Static website hosting is a feature that you have to enable on the storage account.

To enable static website hosting, select the name of your default file, and then optionally provide a path to a custom 404 page. If a blob storage container named $web doesn't already exist in the account, one is created for you. Add the files of your site to this container.

For step-by-step guidance, see Host a static website in Azure Storage.

Files in the $web container are case-sensitive, served through anonymous access requests and are available only through read operations.

Uploading content

You can use any of these tools to upload content to the $web container:

Viewing content

Slots

Users can view site content from a browser by using the public URL of the website. You can find the URL by using the Azure portal, Azure CLI, or PowerShell. See Find the website URL.

If the server returns a 404 error, and you have not specified an error document when you enabled the website, then a default 404 page is returned to the user.

Note

Cross-Origin Resource Sharing (CORS) support for Azure Storage is not supported with static website.

Regional codes

The URL of your site contains a regional code. For example the URL https://contosoblobaccount.z22.web.core.windows.net/ contains regional code z22.

While that code must remain in the URL, it is only for internal use, and you won't have to use that code in any other way.

The index document that you specify when you enable static website hosting, appears when users open the site and don't specify a specific file (For example: https://contosoblobaccount.z22.web.core.windows.net).

Secondary endpoints

If you set up redundancy in a secondary region, you can also access website content by using a secondary endpoint. Because data is replicated to secondary regions asynchronously, the files that are available at the secondary endpoint aren't always in sync with the files that are available on the primary endpoint.

Impact of the setting the public access level of the web container

You can modify the public access level of the $web container, but this has no impact on the primary static website endpoint because these files are served through anonymous access requests. That means public (read-only) access to all files.

The following screenshot shows the public access level setting in the Azure portal:

Azure Function Deployment Slot

While the primary static website endpoint is not affected, a change to the public access level does impact the primary blob service endpoint.

For example, if you change the public access level of the $web container from Private (no anonymous access) to Blob (anonymous read access for blobs only), then the level of public access to the primary static website endpoint https://contosoblobaccount.z22.web.core.windows.net/index.html doesn't change.

However, the public access to the primary blob service endpoint https://contosoblobaccount.blob.core.windows.net/$web/index.html does change from private to public. Now users can open that file by using either of these two endpoints.

Slots

Disabling public access on a storage account does not affect static websites that are hosted in that storage account. For more information, see Configure anonymous public read access for containers and blobs.

Mapping a custom domain to a static website URL

You can make your static website available via a custom domain.

It's easier to enable HTTP access for your custom domain, because Azure Storage natively supports it. To enable HTTPS, you'll have to use Azure CDN because Azure Storage does not yet natively support HTTPS with custom domains. see Map a custom domain to an Azure Blob Storage endpoint for step-by-step guidance.

If the storage account is configured to require secure transfer over HTTPS, then users must use the HTTPS endpoint.

Tip

Consider hosting your domain on Azure. For more information, see Host your domain in Azure DNS.

Adding HTTP headers

There's no way to configure headers as part of the static website feature. However, you can use Azure CDN to add headers and append (or overwrite) header values. See Standard rules engine reference for Azure CDN.

If you want to use headers to control caching, see Control Azure CDN caching behavior with caching rules.

Multi-region website hosting

If you plan to host a website in multiple geographies, we recommend that you use a Content Delivery Network for regional caching. Use Azure Front Door if you want to serve different content in each region. It also provides failover capabilities. Azure Traffic Manager is not recommended if you plan to use a custom domain. Issues can arise because of how Azure Storage verifies custom domain names.

Pricing

Azure Static Website Deployment Slots

You can enable static website hosting free of charge. You're billed only for the blob storage that your site utilizes and operations costs. For more details on prices for Azure Blob Storage, check out the Azure Blob Storage Pricing Page.

Metrics

You can enable metrics on static website pages. Once you've enabled metrics, traffic statistics on files in the $web container are reported in the metrics dashboard.

To enable metrics on your static website pages, see Enable metrics on static website pages.

Next steps

Azure Static Website Deployment Slots Free

This Github Action enables developers to build and publish their applications to Azure App Service Static Web Apps. This action utilizes Oryx to detect and build an application, then uploads the resulting application content, as well as any Azure Functions, to Azure.

Issues and Feedback

If you’d like to report an issue or provide feedback, please create issues against this repository.

This project welcomes contributions and suggestions. Most contributions require you to agree to aContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant usthe rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to providea CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructionsprovided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct.For more information see the Code of Conduct FAQ orcontact opencode@microsoft.com with any additional questions or comments.