Skip to content

Commit 03e7518

Browse files
authored
Merge pull request #206948 from normesta/azurite
Adding info about parameter
2 parents c287cc3 + 0e7b7ef commit 03e7518

File tree

1 file changed

+87
-45
lines changed

1 file changed

+87
-45
lines changed

articles/storage/common/storage-use-azurite.md

Lines changed: 87 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: The Azurite open-source emulator provides a free local environment
44
author: normesta
55

66
ms.author: normesta
7-
ms.date: 06/03/2022
7+
ms.date: 08/04/2022
88
ms.service: storage
99
ms.subservice: common
1010
ms.topic: how-to
@@ -39,21 +39,24 @@ To configure Azurite within Visual Studio Code, select the extensions pane. Sele
3939

4040
The following settings are supported:
4141

42-
- **Azurite: Blob Host** - The Blob service listening endpoint. The default setting is 127.0.0.1.
43-
- **Azurite: Blob Port** - The Blob service listening port. The default port is 10000.
44-
- **Azurite: Cert** - Path to a locally trusted PEM or PFX certificate file path to enable HTTPS mode.
45-
- **Azurite: Debug** - Output the debug log to the Azurite channel. The default value is **false**.
46-
- **Azurite: Key** - Path to a locally trusted PEM key file, required when **Azurite: Cert** points to a PEM file.
47-
- **Azurite: Location** - The workspace location path. The default is the Visual Studio Code working folder.
48-
- **Azurite: Loose** - Enable loose mode, which ignores unsupported headers and parameters.
49-
- **Azurite: Oauth** - Optional OAuth level.
50-
- **Azurite: Pwd** - Password for PFX file. Required when **Azurite: Cert** points to a PFX file.
51-
- **Azurite: Queue Host** - The Queue service listening endpoint. The default setting is 127.0.0.1.
52-
- **Azurite: Queue Port** - The Queue service listening port. The default port is 10001.
53-
- **Azurite: Silent** - Silent mode disables the access log. The default value is **false**.
54-
- **Azurite: Skip Api Version Check** - Skip the request API version check. The default value is **false**.
55-
- **Azurite: Table Host** - The Table service listening endpoint, by default setting is 127.0.0.1.
56-
- **Azurite: Table Port** - The Table service listening port, by default 10002.
42+
- **azurite.blobHost** - The Blob service listening endpoint. The default setting is 127.0.0.1.
43+
- **azurite.blobPort** - The Blob service listening port. The default port is 10000.
44+
- **azurite.queueHost** - The Queue service listening endpoint. The default setting is 127.0.0.1.
45+
- **azurite.queuePort** - The Queue service listening port. The default port is 10001.
46+
- **azurite.tableHost** - The Table service listening endpoint, by default setting is 127.0.0.1.
47+
- **azurite.tablePort** - The Table service listening port, by default 10002.
48+
- **azurite.cert** - Path to a locally trusted PEM or PFX certificate file path to enable HTTPS mode.
49+
- **azurite.debug** - Output the debug log to the Azurite channel. The default value is **false**.
50+
- **azurite.key** - Path to a locally trusted PEM key file, required when
51+
- **azurite.location** - The workspace location path. The default is the Visual Studio Code working folder.
52+
- **azurite.loose** - Enable loose mode, which ignores unsupported headers and parameters.
53+
- **azurite.oauth** - Optional OAuth level.
54+
- **azurite.pwd** - Password for PFX file. Required when **Azurite: Cert** points to a PFX file.
55+
56+
- **azurite.silent** - Silent mode disables the access log. The default value is **false**.
57+
- **azurite.skipApiVersionCheck** - Skip the request API version check. The default value is **false**.
58+
- **azurite.disableProductStyleUrl** Force the parsing of the storage account name from request Uri path, instead of from request Uri host.
59+
5760

5861
### [npm](#tab/npm)
5962

@@ -71,33 +74,6 @@ Use [DockerHub](https://hub.docker.com/) to pull the [latest Azurite image](http
7174
docker pull mcr.microsoft.com/azure-storage/azurite
7275
```
7376

74-
**Run the Azurite Docker image**:
75-
76-
The following command runs the Azurite Docker image. The `-p 10000:10000` parameter redirects requests from host machine's port 10000 to the Docker instance.
77-
78-
```console
79-
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \
80-
mcr.microsoft.com/azure-storage/azurite
81-
```
82-
83-
**Specify the workspace location**:
84-
85-
In the following example, the `-v c:/azurite:/data` parameter specifies *c:/azurite* as the Azurite persisted data location. The directory, *c:/azurite*, must be created before running the Docker command.
86-
87-
```console
88-
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \
89-
-v c:/azurite:/data mcr.microsoft.com/azure-storage/azurite
90-
```
91-
92-
**Run just the blob service**
93-
94-
```console
95-
docker run -p 10000:10000 mcr.microsoft.com/azure-storage/azurite \
96-
azurite-blob --blobHost 0.0.0.0 --blobPort 10000
97-
```
98-
99-
For more information about configuring Azurite at start-up, see [Command-line options](#command-line-options).
100-
10177
### [GitHub](#tab/github)
10278

10379
This installation method requires that you have [Git](https://git-scm.com/) and [Node.js version 8.0 or later](https://nodejs.org) installed. Clone the [GitHub repository](https://github.com/azure/azurite) for the Azurite project by using the following console command.
@@ -192,6 +168,24 @@ This command tells Azurite to store all data in a particular directory, *c:\azur
192168

193169
### [Docker Hub](#tab/docker-hub)
194170

171+
**Run the Azurite Docker image**:
172+
173+
The following command runs the Azurite Docker image. The `-p 10000:10000` parameter redirects requests from host machine's port 10000 to the Docker instance.
174+
175+
```console
176+
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \
177+
mcr.microsoft.com/azure-storage/azurite
178+
```
179+
180+
**Specify the workspace location**:
181+
182+
In the following example, the `-v c:/azurite:/data` parameter specifies *c:/azurite* as the Azurite persisted data location. The directory, *c:/azurite*, must be created before running the Docker command.
183+
184+
```console
185+
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \
186+
-v c:/azurite:/data mcr.microsoft.com/azure-storage/azurite
187+
```
188+
195189
**Run just the blob service**
196190

197191
```console
@@ -432,6 +426,14 @@ Azurite supports basic authentication by specifying the `basic` parameter to the
432426
azurite --skipApiVersionCheck
433427
```
434428

429+
### Disable Production Style Url
430+
431+
**Optional**. When using the fully-qualified domain name instead of the IP in request Uri host, by default Azurite will parse the storage account name from request Uri host. You can force the parsing of the storage account name from request Uri path by using `--disableProductStyleUrl`:
432+
433+
```cmd
434+
azurite --disableProductStyleUrl
435+
```
436+
435437
## Authorization for tools and SDKs
436438

437439
Connect to Azurite from Azure Storage SDKs or tools, like [Azure Storage Explorer](https://azure.microsoft.com/features/storage-explorer/), by using any authentication strategy. Authentication is required. Azurite supports authorization with OAuth, Shared Key, and shared access signatures (SAS). Azurite also supports anonymous access to public containers.
@@ -447,7 +449,7 @@ Azurite accepts the same well-known account and key used by the legacy Azure Sto
447449

448450
### Custom storage accounts and keys
449451

450-
Azurite supports custom storage account names and keys by setting the `AZURITE_ACCOUNTS` environment variable in the following format: `account1:key1[:key2];account2:key1[:key2];...`.
452+
Azurite supports custom storage account names and keys by setting the `AZURITE_ACCOUNTS` environment variable in the following format: `account1:key1[:key2];account2:key1[:key2];...`.
451453

452454
For example, use a custom storage account that has one key:
453455

@@ -459,6 +461,9 @@ set AZURITE_ACCOUNTS="account1:key1"
459461
export AZURITE_ACCOUNTS="account1:key1"
460462
```
461463

464+
> [!NOTE]
465+
> The account keys must be a base64 encoded string.
466+
462467
Or use multiple storage accounts with two keys each:
463468

464469
```cmd
@@ -474,6 +479,8 @@ Azurite refreshes custom account names and keys from the environment variable ev
474479
> [!NOTE]
475480
> The default `devstoreaccount1` storage account is disabled when you set custom storage accounts.
476481
482+
The account keys must be a base64 encoded string.
483+
477484
### Connection strings
478485

479486
The easiest way to connect to Azurite from your application is to configure a connection string in your application's configuration file that references the shortcut *UseDevelopmentStorage=true*. Here's an example of a connection string in an *app.config* file:
@@ -679,14 +686,49 @@ The following URI is a valid address for a blob in an Azure Storage account:
679686

680687
`https://myaccount.blob.core.windows.net/mycontainer/myblob.txt`
681688

682-
Since the local computer doesn't do domain name resolution, the account name is part of the URI path instead of the host name. Use the following URI format for a resource in Azurite:
689+
690+
#### IP-style URL
691+
692+
Since the local computer doesn't resolve domain names, the account name is part of the URI path instead of the host name. Use the following URI format for a resource in Azurite:
683693

684694
`http://<local-machine-address>:<port>/<account-name>/<resource-path>`
685695

686696
The following address might be used for accessing a blob in Azurite:
687697

688698
`http://127.0.0.1:10000/myaccount/mycontainer/myblob.txt`
689699

700+
#### Production-style URL
701+
702+
Optionally, you could modify your hosts file to access an account with _production-style_ URL.
703+
704+
First, add one or more lines to your hosts file. For example:
705+
706+
```
707+
127.0.0.1 account1.blob.localhost
708+
127.0.0.1 account1.queue.localhost
709+
127.0.0.1 account1.table.localhost
710+
```
711+
712+
Next, set environment variables to enable customized storage accounts and keys:
713+
714+
```
715+
set AZURITE_ACCOUNTS="account1:key1:key2"
716+
```
717+
718+
You could add more accounts. See the [Custom storage accounts and keys](#custom-storage-accounts-and-keys) section of this article.
719+
720+
Start Azurite and use a customized connection string to access your account. The example connection string below assumes that the default ports are used.
721+
722+
```
723+
DefaultEndpointsProtocol=http;AccountName=account1;AccountKey=key1;BlobEndpoint=http://account1.blob.localhost:10000;QueueEndpoint=http://account1.queue.localhost:10001;TableEndpoint=http://account1.table.localhost:10002;
724+
```
725+
726+
Do not access default account in this way with Azure Storage Explorer. There is a bug that Storage Explorer is always adding account name in URL path, causing failures.
727+
728+
By default, when using Azurite with a production-style URL, the account name should be the host name in fully-qualified domain name such as "http://devstoreaccount1.blob.localhost:10000/container". To use production-style URL with account name in the URL path such as "http://foo.bar.com:10000/devstoreaccount1/container", make sure to use the `--disableProductStyleUrl` parameter when you start Azurite.
729+
730+
If use `host.docker.internal` as request Uri host (For example: `http://host.docker.internal:10000/devstoreaccount1/container`), Azurite will always get the account name from the request Uri path. This is true regardless of whether you use the `--disableProductStyleUrl` parameter when you start Azurite.
731+
690732
### Scaling and performance
691733

692734
Azurite doesn't support large numbers of connected clients. There's no performance guarantee. Azurite is intended for development and testing purposes.

0 commit comments

Comments
 (0)