Skip to content

Commit 2c9c97c

Browse files
authored
Merge pull request #106551 from normesta/normesta-static-websites
Fixing up the static page
2 parents 3980eb0 + 21f1dbf commit 2c9c97c

File tree

5 files changed

+113
-68
lines changed

5 files changed

+113
-68
lines changed
-63.4 KB
Loading
16.8 KB
Loading
23.2 KB
Loading

articles/storage/blobs/storage-blob-static-website-host.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ Next, create a Hello World web page with Visual Studio Code and deploy it to the
8888
8989
Visual Studio Code will now upload your files to your web endpoint, and show the success status bar. Launch the website to view it in Azure.
9090
91-
![View static website deployment in Azure](media/storage-blob-static-website-host/view-static-website-endpoint.png)
92-
93-
You’ve successfully completed the tutorial and deployed a static website to Azure.
91+
You've successfully completed the tutorial and deployed a static website to Azure.
9492
9593
## Next steps
9694

articles/storage/blobs/storage-blob-static-website-how-to.md

Lines changed: 112 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: storage
66
ms.subservice: blobs
77
ms.topic: conceptual
88
ms.author: normesta
9-
ms.date: 05/28/2019
9+
ms.date: 03/04/2020
1010
---
1111

1212
# Host a static website in Azure Storage
@@ -15,25 +15,35 @@ You can serve static content (HTML, CSS, JavaScript, and image files) directly f
1515

1616
This article shows you how to enable static website hosting by using the Azure portal, the Azure CLI, or PowerShell.
1717

18-
<a id="portal" />
18+
## Enable static website hosting
1919

20-
## [Portal](#tab/azure-portal)
20+
Static website hosting is a feature that you have to enable on the storage account.
2121

22-
For a step-by-step tutorial, see [Tutorial: Host a static website on Blob Storage](https://docs.microsoft.com/azure/storage/blobs/storage-blob-static-website-host).
22+
### [Portal](#tab/azure-portal)
2323

24-
After you enable static website hosting, you can view the pages of your site from a browser by using the public URL of the website.
24+
1. Sign in to the [Azure portal](https://portal.azure.com/) to get started.
2525

26-
<a id="portal-find-url" />
26+
2. Locate your storage account and display the account overview.
2727

28-
### Find the website URL by using the Azure portal
28+
3. Select **Static website** to display the configuration page for static websites.
2929

30-
In the pane that appears beside the account overview page of your storage account, select **Static Website**. The URL of your site appears in the **Primary endpoint** field.
30+
4. Select **Enabled** to enable static website hosting for the storage account.
3131

32-
![Azure Storage static websites metrics metric](./media/storage-blob-static-website/storage-blob-static-website-url.png)
32+
5. In the **Index document name** field, specify a default index page (For example: *index.html*).
3333

34-
<a id="cli" />
34+
The default index page is displayed when a user navigates to the root of your static website.
35+
36+
6. In the **Error document path** field, specify a default error page (For example: *404.html*).
37+
38+
The default error page is displayed when a user attempts to navigate to a page that does not exist in your static website.
3539

36-
## [Azure CLI](#tab/azure-cli)
40+
7. Click **Save**. The Azure portal now displays your static website endpoint.
41+
42+
![Enable static website hosting for a storage account](media/storage-blob-static-website-host/enable-static-website-hosting.png)
43+
44+
### [Azure CLI](#tab/azure-cli)
45+
46+
<a id="cli" />
3747

3848
You can enable static website hosting by using the [Azure Command-Line Interface (CLI)](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest).
3949

@@ -59,46 +69,10 @@ You can enable static website hosting by using the [Azure Command-Line Interface
5969

6070
* Replace the `<index-document-name>` placeholder with the name of the index document. This document is commonly "index.html".
6171

62-
4. Upload objects to the *$web* container from a source directory.
63-
64-
> [!NOTE]
65-
> If you're using Azure Cloud Shell, make sure to add an `\` escape character when referring to the `$web` container (For example: `\$web`). If you're using a local installation of the Azure CLI, then you won't have to use the escape character.
66-
67-
This example assumes that you're running commands from Azure Cloud Shell session.
68-
69-
```azurecli-interactive
70-
az storage blob upload-batch -s <source-path> -d \$web --account-name <storage-account-name> --content-type 'text/html; charset=utf-8'
71-
```
72-
73-
* Replace the `<storage-account-name>` placeholder value with the name of your storage account.
74-
75-
* Replace the `<source-path>` placeholder with a path to the location of the files that you want to upload.
76-
77-
> [!NOTE]
78-
> If you're using a location installation of Azure CLI, then you can use the path to any location on your local computer (For example: `C:\myFolder`.
79-
>
80-
> If you're using Azure Cloud Shell, you'll have to reference a file share that is visible to the Cloud Shell. This location could be the file share of the Cloud share itself or an existing file share that you mount from the Cloud Shell. To learn how to do this, see [Persist files in Azure Cloud Shell](https://docs.microsoft.com/azure/cloud-shell/persisting-shell-storage).
81-
82-
<a id="cli-find-url" />
83-
84-
### Find the website URL by using the Azure CLI
85-
86-
You can view content from a browser by using the public URL of the website.
87-
88-
Find the URL by using the following command:
89-
90-
```azurecli-interactive
91-
az storage account show -n <storage-account-name> -g <resource-group-name> --query "primaryEndpoints.web" --output tsv
92-
```
93-
94-
* Replace the `<storage-account-name>` placeholder value with the name of your storage account.
95-
96-
* Replace the `<resource-group-name>` placeholder value with the name of your resource group.
72+
### [PowerShell](#tab/azure-powershell)
9773

9874
<a id="powershell" />
9975

100-
## [PowerShell](#tab/azure-powershell)
101-
10276
You can enable static website hosting by using the Azure PowerShell module.
10377

10478
1. Open a Windows PowerShell command window.
@@ -147,28 +121,101 @@ You can enable static website hosting by using the Azure PowerShell module.
147121

148122
* Replace the `<index-document-name>` placeholder with the name of the index document. This document is commonly "index.html".
149123

150-
7. Upload objects to the *$web* container from a source directory.
124+
---
151125

152-
```powershell
153-
# upload a file
154-
set-AzStorageblobcontent -File "<path-to-file>" `
155-
-Properties @{ ContentType = "text/html; charset=utf-8";} `
156-
-Container `$web `
157-
-Blob "<blob-name>" `
158-
-Context $ctx
159-
```
126+
## Upload files
160127

161-
* Replace the `<path-to-file>` placeholder value with the fully qualified path to the file that you want to upload (For example: `C:\temp\index.html`).
128+
### [Portal](#tab/azure-portal)
162129

163-
* Replace the `<blob-name>` placeholder value with the name that you want to give the resulting blob (For example: `index.html`).
130+
These instructions show you how to upload files by using the version of Storage Explorer that appears in the Azure portal. However, you can also use the version of [Storage Explorer](https://azure.microsoft.com/features/storage-explorer/) that runs outside of the Azure portal. You could use [AzCopy](../common/storage-use-azcopy-v10.md), PowerShell, CLI, or any custom application that can upload files to the **$web** container of your account. For a step-by-step tutorial that uploads files by using Visual Studio code, see [Tutorial: Host a static website on Blob Storage](https://docs.microsoft.com/azure/storage/blobs/storage-blob-static-website-host).
164131

165-
<a id="powershell-find-url" />
132+
1. Select **Storage Explorer (preview)**.
133+
134+
2. Expand the **BLOB CONTAINERS** node, and then select the **$web** container.
135+
136+
3. Choose the **Upload** button to upload files.
137+
138+
![Upload files](media/storage-blob-static-website/storage-blob-static-website-upload.png)
139+
140+
4. If you intend for the browser to display the contents of file, make sure that the content type of that file is set to `text/html`.
166141

167-
### Find the website URL by using PowerShell
142+
![Check content types](media/storage-blob-static-website/storage-blob-static-website-content-type.png)
168143

169-
You can view content from a browser by using the public URL of the website.
144+
>[!NOTE]
145+
> Storage Explorer automatically sets this property to `text/html` for commonly recognized extensions such as `.html`. However, in some cases, you'll have to set this yourself. If you don't set this property to `text/html`, the browser will prompt users to download the file instead of rendering the contents. To set this property, right-click the file, and then click **Properties**.
170146
171-
Find the URL by using the following command:
147+
### [Azure CLI](#tab/azure-cli)
148+
149+
Upload objects to the *$web* container from a source directory.
150+
151+
> [!NOTE]
152+
> If you're using Azure Cloud Shell, make sure to add an `\` escape character when referring to the `$web` container (For example: `\$web`). If you're using a local installation of the Azure CLI, then you won't have to use the escape character.
153+
154+
This example assumes that you're running commands from Azure Cloud Shell session.
155+
156+
```azurecli-interactive
157+
az storage blob upload-batch -s <source-path> -d \$web --account-name <storage-account-name> --content-type 'text/html; charset=utf-8'
158+
```
159+
160+
* Replace the `<storage-account-name>` placeholder value with the name of your storage account.
161+
162+
* Replace the `<source-path>` placeholder with a path to the location of the files that you want to upload.
163+
164+
> [!NOTE]
165+
> If you're using a location installation of Azure CLI, then you can use the path to any location on your local computer (For example: `C:\myFolder`.
166+
>
167+
> If you're using Azure Cloud Shell, you'll have to reference a file share that is visible to the Cloud Shell. This location could be the file share of the Cloud share itself or an existing file share that you mount from the Cloud Shell. To learn how to do this, see [Persist files in Azure Cloud Shell](https://docs.microsoft.com/azure/cloud-shell/persisting-shell-storage).
168+
169+
### [PowerShell](#tab/azure-powershell)
170+
171+
Upload objects to the *$web* container from a source directory.
172+
173+
```powershell
174+
# upload a file
175+
set-AzStorageblobcontent -File "<path-to-file>" `
176+
-Properties @{ ContentType = "text/html; charset=utf-8";} `
177+
-Container `$web `
178+
-Blob "<blob-name>" `
179+
-Context $ctx
180+
```
181+
182+
* Replace the `<path-to-file>` placeholder value with the fully qualified path to the file that you want to upload (For example: `C:\temp\index.html`).
183+
184+
* Replace the `<blob-name>` placeholder value with the name that you want to give the resulting blob (For example: `index.html`).
185+
186+
---
187+
188+
## Find the website URL by using the Azure portal
189+
190+
You can view the pages of your site from a browser by using the public URL of the website.
191+
192+
### [Portal](#tab/azure-portal)
193+
194+
<a id="portal-find-url" />
195+
196+
In the pane that appears beside the account overview page of your storage account, select **Static Website**. The URL of your site appears in the **Primary endpoint** field.
197+
198+
![Azure Storage static websites metrics metric](./media/storage-blob-static-website/storage-blob-static-website-url.png)
199+
200+
### [Azure CLI](#tab/azure-cli)
201+
202+
<a id="cli-find-url" />
203+
204+
Find the public URL of your static website by using the following command:
205+
206+
```azurecli-interactive
207+
az storage account show -n <storage-account-name> -g <resource-group-name> --query "primaryEndpoints.web" --output tsv
208+
```
209+
210+
* Replace the `<storage-account-name>` placeholder value with the name of your storage account.
211+
212+
* Replace the `<resource-group-name>` placeholder value with the name of your resource group.
213+
214+
### [PowerShell](#tab/azure-powershell)
215+
216+
<a id="powershell-find-url" />
217+
218+
Find the public URL of your static website by using by using the following command:
172219

173220
```powershell
174221
$storageAccount = Get-AzStorageAccount -ResourceGroupName "<resource-group-name>" -Name "<storage-account-name>"
@@ -179,10 +226,10 @@ Write-Output $storageAccount.PrimaryEndpoints.Web
179226

180227
* Replace the `<storage-account-name>` placeholder value with the name of your storage account.
181228

182-
<a id="metrics" />
183-
184229
---
185230

231+
<a id="metrics" />
232+
186233
## Enable metrics on static website pages
187234

188235
Once you've enabled metrics, traffic statistics on files in the **$web** container are reported in the metrics dashboard.

0 commit comments

Comments
 (0)