UNPKG

38.8 kBMarkdownView Raw
1# Azurite V3
2
3[![npm version](https://badge.fury.io/js/azurite.svg)](https://badge.fury.io/js/azurite)
4[![Build Status](https://dev.azure.com/azure/Azurite/_apis/build/status/Azure.Azurite?branchName=master)](https://dev.azure.com/azure/Azurite/_build/latest?definitionId=20&branchName=master)
5
6> Note:
7> Azurite V2 has been moved to [legacy-master](https://github.com/Azure/azurite/tree/legacy-master) branch.
8> Master branch has been updated with latest Azurite V3.
9> V3 currently only supports Blob and Queue service, please use V2 for Table service for the time being.
10
11| Version | Azure Storage API Version | Service Support | Description | Reference Links |
12| ------------------------------------------------------------------ | ------------------------- | --------------------- | ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
13| 3.8.0 | 2019-12-12 | Blob<br>Queue | Azurite V3 based on TypeScript & New Architecture | [NPM](https://www.npmjs.com/package/azurite) - [Docker](https://hub.docker.com/_/microsoft-azure-storage-azurite) - [Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=Azurite.azurite) |
14| [Legacy (v2)](https://github.com/Azure/Azurite/tree/legacy-master) | 2016-05-31 | Blob, Queue and Table | Legacy Azurite V2 | [NPM](https://www.npmjs.com/package/azurite) |
15
16## Introduction
17
18Azurite is an open source Azure Storage API compatible server (emulator). Based on Node.js, Azurite provides cross platform experiences for customers wanting to try Azure Storage easily in a local environment. Azurite simulates most of the commands supported by Azure Storage with minimal dependencies.
19
20Azurite V2 is manually created with pure JavaScript, popular and active as an open source project. However, Azure Storage APIs are growing and keeping updating, manually keeping Azurite up to date is not efficient and prone to bugs. JavaScript also lacks strong type validation which prevents easy collaboration.
21
22Compared to V2, Azurite V3 implements a new architecture leveraging code generated by a TypeScript Server Code Generator we created. The generator uses the same swagger (modified) used by the new Azure Storage SDKs. This reduces manual effort and more facilitates better code alignment with storage APIs.
23
243.0.0-preview is the first release version using Azurite's new architecture.
25
26## Features & Key Changes in Azurite V3
27
28- Blob storage features align with Azure Storage API version 2019-12-12 (Refer to support matrix section below)
29 - SharedKey/Account SAS/Service SAS/Public Access Authentications
30 - Get/Set Blob Service Properties
31 - Create/List/Delete Containers
32 - Create/Read/List/Update/Delete Block Blobs
33 - Create/Read/List/Update/Delete Page Blobs
34- Queue storage features align with Azure Storage API version 2019-12-12 (Refer to support matrix section below)
35 - SharedKey/Account SAS/Service SAS
36 - Get/Set Queue Service Properties
37 - Preflight Request
38 - Create/List/Delete Queues
39 - Put/Get/Peek/Updata/Deleta/Clear Messages
40- Features **NEW** on V3
41 - Built with TypeScript and ECMA native promise and async features
42 - New architecture based on TypeScript server generator. Leverage auto generated protocol layer, models, serializer, deserializer and handler interfaces from REST API swagger
43 - Flexible structure and architecture, supports customizing handler layer implementation, persistency layer implementation, HTTP pipeline middleware injection
44 - Detailed debugging log support, easy bug locating and reporting
45 - Works with storage .Net SDK basic and advanced sample
46 - SharedKey, AccountSAS, ServiceSAS, OAuth, Public Access authentication support
47 - Keep updating with latest Azure Storage API version features (Refer to support matrix)
48
49## Getting Started
50
51Try with any of following ways to start an Azurite V3 instance.
52
53### GitHub
54
55After cloning source code, execute following commands to install and start Azurite V3.
56
57```bash
58npm ci
59npm run build
60npm install -g
61azurite
62```
63
64### NPM
65
66In order to run Azurite V3 you need Node.js >= 8.0 installed on your system. Azurite works cross-platform on Windows, Linux, and OS X.
67
68After installation you can install Azurite simply with npm which is the Node.js package management tool included with every Node.js installation.
69
70```cmd
71npm install -g azurite
72```
73
74Simply start it with the following command:
75
76```cmd
77azurite -s -l c:\azurite -d c:\azurite\debug.log
78```
79
80or,
81
82```cmd
83azurite --silent --location c:\azurite --debug c:\azurite\debug.log
84```
85
86This tells Azurite to store all data in a particular directory `c:\azurite`. If the `-l` option is omitted it will use the current working directory. You can also selectively start different storage services.
87
88For example, to start blob service only:
89
90```bash
91$ azurite-blob -l path/to/azurite/workspace
92```
93
94Start queue service only:
95
96```bash
97$ azurite-queue -l path/to/azurite/workspace
98```
99
100### Visual Studio Code Extension
101
102Azurite V3 can be installed from [Visual Studio Code extension market](https://marketplace.visualstudio.com/items?itemName=Azurite.azurite).
103
104You can quickly start or close Azurite by clicking Azurite **status bar item** or following commands.
105
106Extension supports following Visual Studio Code commands:
107
108- `Azurite: Start` Start all Azurite services
109- `Azurite: Close` Close all Azurite services
110- `Azurite: Clean` Reset all Azurite services persistency data
111- `Azurite: Start Blob Service` Start blob service
112- `Azurite: Close Blob Service` Close blob service
113- `Azurite: Clean Blob Service` Clean blob service
114- `Azurite: Start Queue Service` Start queue service
115- `Azurite: Close Queue Service` Close queue service
116- `Azurite: Clean Queue Service` Clean queue service
117
118Following extension configurations are supported:
119
120- `azurite.blobHost` Blob service listening endpoint, by default 127.0.0.1
121- `azurite.blobPort` Blob service listening port, by default 10000
122- `azurite.queueHost` Queue service listening endpoint, by default 127.0.0.1
123- `azurite.queuePort` Queue service listening port, by default 10001
124- `azurite.location` Workspace location path, by default existing Visual Studio Code opened folder
125- `azurite.silent` Silent mode to disable access log in Visual Studio channel, by default false
126- `azurite.debug` Output debug log into Azurite channel, by default false
127- `azurite.loose` Enable loose mode which ignores unsupported headers and parameters, by default false
128- `azurite.cert` Path to a PEM or PFX cert file. Required by HTTPS mode.
129- `azurite.key` Path to a PEM key file. Required when `azurite.cert` points to a PEM file.
130- `azurite.pwd` PFX cert password. Required when `azurite.cert` points to a PFX file.
131- `azurite.oauth` OAuth oauthentication level. Candidate level values: `basic`.
132- `azurite.skipApiVersionCheck` Skip the request API version check, by default false.
133
134### [DockerHub](https://hub.docker.com/_/microsoft-azure-storage-azurite)
135
136#### Run Azurite V3 docker image
137
138> Note. Find more docker images tags in https://mcr.microsoft.com/v2/azure-storage/azurite/tags/list
139
140```bash
141docker run -p 10000:10000 -p 10001:10001 mcr.microsoft.com/azure-storage/azurite
142```
143
144`-p 10000:10000` will expose blob service's default listening port.
145`-p 10001:10001` will expose queue service's default listening port.
146
147Or just run blob service:
148
149```bash
150docker run -p 10000:10000 mcr.microsoft.com/azure-storage/azurite azurite-blob --blobHost 0.0.0.0
151```
152
153#### Run Azurite V3 docker image with customized persisted data location
154
155```bash
156docker run -p 10000:10000 -p 10001:10001 -v c:/azurite:/data mcr.microsoft.com/azure-storage/azurite
157```
158
159`-v c:/azurite:/data` will use and map host path `c:/azurite` as Azurite's workspace location.
160
161#### Customize all Azurite V3 supported parameters for docker image
162
163```bash
164docker run -p 8888:8888 -p 9999:9999 -v c:/azurite:/workspace mcr.microsoft.com/azure-storage/azurite azurite -l /workspace -d /workspace/debug.log --blobPort 8888 --blobHost 0.0.0.0 --queuePort 9999 --queueHost 0.0.0.0 --loose --skipApiVersionCheck
165```
166
167Above command will try to start Azurite image with configurations:
168
169`-l //workspace` defines folder `/workspace` as Azurite's location path inside docker instance, while `/workspace` is mapped to `c:/azurite` in host environment by `-v c:/azurite:/workspace`
170
171`-d //workspace/debug.log` enables debug log into `/workspace/debug.log` inside docker instance. `debug.log` will also mapped to `c:/azurite/debug.log` in host machine because of docker volume mapping.
172
173`--blobPort 8888` makes Azurite blob service listen to port 8888, while `-p 8888:8888` redirects requests from host machine's port 8888 to docker instance.
174
175`--blobHost 0.0.0.0` defines blob service listening endpoint to accept requests from host machine.
176
177`--queuePort 9999` makes Azurite queue service listen to port 9999, while `-p 9999:9999` redirects requests from host machine's port 9999 to docker instance.
178
179`--queueHost 0.0.0.0` defines queue service listening endpoint to accept requests from host machine.
180
181`--loose` enables loose mode which ignore unsupported headers and parameters.
182
183`--skipApiVersionCheck` skip the request API version check.
184
185> In above sample, you need to use **double first forward slash** for location and debug path parameters to avoid a [known issue](https://stackoverflow.com/questions/48427366/docker-build-command-add-c-program-files-git-to-the-path-passed-as-build-argu) for Git on Windows.
186
187> Will support more release channels for Azurite V3 in the future.
188
189### NuGet
190
191_Releasing Azurite V3 to NuGet is under investigation._
192
193### Visual Studio
194
195_Integrate Azurite with Visual Studio is under investigation._
196
197## Supported Command Line Options
198
199### Listening Host Configuration
200
201Optional. By default, Azurite V3 will listen to 127.0.0.1 as a local server.
202You can customize the listening address per your requirements.
203
204#### Only Accept Requests in Local Machine
205
206```cmd
207--blobHost 127.0.0.1
208--queueHost 127.0.0.1
209```
210
211#### Allow Accepting Requests from Remote (potentially unsafe)
212
213```cmd
214--blobHost 0.0.0.0
215--queueHost 0.0.0.0
216```
217
218### Listening Port Configuration
219
220Optional. By default, Azurite V3 will listen to 10000 as blob service port, and 10001 as queue service port.
221You can customize the listening port per your requirements.
222
223> Warning: After using a customized port, you need to update connection string or configurations correspondingly in your Storage Tools or SDKs.
224
225#### Customize Blob/Queue Service Listening Port
226
227```cmd
228--blobPort 8888
229--queuePort 9999
230```
231
232#### Let System Auto Select an Available Port
233
234```cmd
235--blobPort 0
236--queuePort 0
237```
238
239> Note: The port in use is displayed on Azurite startup.
240
241### Workspace Path Configuration
242
243Optional. Azurite V3 needs to persist metadata and binary data to local disk during execution.
244
245You can provide a customized path as the workspace location, or by default, Current process working directory will be used.
246
247```cmd
248-l c:\azurite
249--location c:\azurite
250```
251
252### Access Log Configuration
253
254Optional. By default Azurite will display access log in console. **Disable** it by:
255
256```cmd
257-s
258--silent
259```
260
261### Debug Log Configuration
262
263Optional. Debug log includes detailed information on every request and exception stack traces.
264Enable it by providing a valid local file path for the debug log destination.
265
266```cmd
267-d path/debug.log
268--debug path/debug.log
269```
270
271### Loose Mode Configuration
272
273Optional. By default Azurite will apply strict mode. Strict mode will block unsupported request headers or parameters. **Disable** it by enabling loose mode:
274
275```cmd
276-L
277--loose
278```
279
280### Certificate Configuration (HTTPS)
281
282Optional. By default Azurite will listen on HTTP protocol. Provide a PEM or PFX certificate file path to enable HTTPS mode:
283
284```cmd
285--cert path/server.pem
286```
287
288When `--cert` is provided for a PEM file, must provide coresponding `--key`.
289
290```cmd
291--key path/key.pem
292```
293
294When `--cert` is provided for a PFX file, must provide coresponding `--pwd`
295
296```cmd
297--pwd pfxpassword
298```
299
300### OAuth Configuration
301
302Optional. By default, Azurite doesn't support OAuth and bearer token. Enable OAuth authentication for Azurite by:
303
304```
305--oauth basic
306```
307
308> Note. OAuth requires HTTPS endpoint. Make sure HTTPS is enabled by providing `--cert` parameter along with `--oauth` parameter.
309
310Currently, Azurite supports following OAuth authentication levels:
311
312#### Basic
313
314In basic level, `--oauth basic`, Azurite will do basic authentication, like validating incoming bearer token, checking issuer, audience, expiry. But Azurite will NOT check token signature and permission.
315
316### Skip API Version Check
317
318Optional. By default Azurite will check the request API version is valid API version. Skip the API version check by:
319
320```cmd
321--skipApiVersionCheck
322```
323
324### Command Line Options Differences between Azurite V2
325
326Azurite V3 supports SharedKey, Account Shared Access Signature (SAS), Service SAS, OAuth, and Public Container Access authentications, you can use any Azure Storage SDKs or tools like Storage Explorer to connect Azurite V3 with any authentication strategy.
327
328An option to bypass authentication is **NOT** provided in Azurite V3.
329
330## Supported Environment Variable Options
331
332When starting Azurite from npm command line `azurite` or docker image, following environment variables are supported for advanced customization.
333
334### Customized Storage Accounts & Keys
335
336Azurite V3 allows customizing storage account names and keys by providing environment variable `AZURITE_ACCOUNTS` with format `account1:key1[:key2];account2:key1[:key2];...`.
337
338For example, customize one storage account which has only one key:
339
340```cmd
341set AZURITE_ACCOUNTS="account1:key1"
342```
343
344Or customize multi storage accounts and each has 2 keys:
345
346```cmd
347set AZURITE_ACCOUNTS="account1:key1:key2;account2:key1:key2"
348```
349
350Azurite will refresh customized account name and key from environment variable every minute by default. With this feature, we can dynamically rotate account key, or add new storage accounts on the air without restarting Azurite instance.
351
352> Note. Default storage account `devstoreaccount1` will be disabled when providing customized storage accounts.
353
354> Note. Should update connection string accordingly if using customized account name and key.
355
356> Note. Use `export` keyword to set environment variable in Linux like environment, `set` in Windows.
357
358### Customized Metadata Storage by External Database (Preview)
359
360By default, Azurite leverages [loki](https://github.com/techfort/LokiJS) as metadata database.
361However, as an in-memory database, loki limits Azurite's scalability and data persistency.
362Set environment variable `AZURITE_DB=dialect://[username][:password][@]host:port/database` to make Azurite blob service switch to a SQL database based metadata storage, like MySql, SqlServer.
363
364For example, connect to MySql or SqlServer by set environment variables:
365
366```bash
367set AZURITE_DB=mysql://username:password@localhost:3306/azurite_blob
368set AZURITE_DB=mssql://username:password@localhost:1024/azurite_blob
369```
370
371When Azurite starts with above environment variable, it connects to the configured database, and creates tables if not exist.
372This feature is in preview, when Azurite changes database table schema, you need to drop existing tables and let Azurite regenerate database tables.
373
374> Note. Need to manually create database before starting Azurite instance.
375
376> Note. Blob Copy & Page Blob are not supported by SQL based metadata implementation.
377
378> Tips. Create database instance quickly with docker, for example `docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest`. Grant external access and create database `azurite_blob` using `docker exec mysql mysql -u root -pmy-secret-pw -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES; create database azurite_blob;"`. Notice that, above commands are examples, you need to carefully define the access permissions in your production environment.
379
380## HTTPS Setup
381
382Azurite natively supports HTTPS with self-signed certificates via the `--cert` and `--key`/`--pwd` options. You have two certificate type options: PEM or PFX. PEM certificates are split into "cert" and "key" files. A PFX certificate is a single file that can be assigned a password.
383
384### PEM
385
386#### Generate PEM Certificate and Key
387
388You have a few options to generate PEM certificate and key files. We'll show you how to use [mkcert](https://github.com/FiloSottile/mkcert) and [OpenSSL](https://www.openssl.org/).
389
390##### mkcert
391
392[mkcert](https://github.com/FiloSottile/mkcert) is a utility that makes the entire self-signed certificate process much easier because it wraps a lot of the complex commands that you need to manually execute with other utilities.
393
394###### Generate Certificate and Key with mkcert
395
3961. Install mkcert: https://github.com/FiloSottile/mkcert#installation. We like to use choco `choco install mkcert`, but you can install with any mechanism you'd like.
3972. Run the following commands to install the Root CA and generate a cert for Azurite.
398
399```bash
400mkcert -install
401mkcert 127.0.0.1
402```
403
404That will create two files. A certificate file: `127.0.0.1.pem` and a key file: `127.0.0.1-key.pem`.
405
406###### Start Azurite with HTTPS and PEM
407
408Then you start Azurite with that cert and key.
409
410```bash
411azurite --cert 127.0.0.1.pem --key 127.0.0.1-key.pem
412```
413
414NOTE: If you are using the Azure SDKs, then you will also need to pass the `--oauth basic` option.
415
416##### OpenSSL
417
418[OpenSSL](https://www.openssl.org/) is a TLS/SSL toolkit. You can use it to generate certificates. It is more involved than mkcert, but has more options.
419
420###### Install OpenSSL on Windows
421
4221. Download and install the OpenSSL v1.1.1a+ EXE from http://slproweb.com/products/Win32OpenSSL.html
4232. Set the following environment variables
424
425```bash
426set OPENSSL_CONF=c:\OpenSSL-Win32\bin\openssl.cfg
427set Path=%PATH%;c:\OpenSSL-Win32\bin
428```
429
430###### Generate Certificate and Key
431
432Execute the following command to generate a cert and key with [OpenSSL](https://www.openssl.org/).
433
434```bash
435openssl req -newkey rsa:2048 -x509 -nodes -keyout key.pem -new -out cert.pem -sha256 -days 365 -addext "subjectAltName=IP:127.0.0.1" -subj "/C=CO/ST=ST/L=LO/O=OR/OU=OU/CN=CN"
436```
437
438The `-subj` values are required, but do not have to be valid. The `subjectAltName` must contain the Azurite IP address.
439
440###### Add Certificate to Trusted Root Store
441
442You then need to add that certificate to the Trusted Root Certification Authorities. This is required to work with Azure SDKs and Storage Explorer.
443
444Here's how to do that on Windows:
445
446```bash
447certutil –addstore -enterprise –f "Root" cert.pem
448```
449
450#### Start Azurite with HTTPS and PEM
451
452Then you start Azurite with that cert and key.
453
454```bash
455Azurite --cert cert.pem --key key.pem
456```
457
458NOTE: If you are using the Azure SDKs, then you will also need to pass the `--oauth basic` option.
459
460#### PFX
461
462##### Generate PFX Certificate
463
464You first need to generate a PFX file to use with Azurite.
465
466You can use the following command to generate a PFX file with `dotnet dev-certs`, which is installed with the [.NET Core SDK](https://dotnet.microsoft.com/download).
467
468```bash
469dotnet dev-certs https --trust -ep cert.pfx -p <password>
470```
471
472> Storage Explorer does not currently work with certificates produced by `dotnet dev-certs`. While you can use them for Azurite and Azure SDKs, you won't be able to access the Azurite endpoints with Storage Explorer if you are using the certs created with dotnet dev-certs. We are tracking this issue on GitHub here: https://github.com/microsoft/AzureStorageExplorer/issues/2859
473
474##### Start Azurite with HTTPS and PFX
475
476Then you start Azurite with that cert and key.
477
478```bash
479azurite --cert cert.pem --key key.pem
480```
481
482NOTE: If you are using the Azure SDKs, then you will also need to pass the `--oauth basic` option.
483
484##### Start Azurite
485
486## Usage with Azure Storage SDKs or Tools
487
488### Default Storage Account
489
490Azurite V3 provides support for a default storage account as General Storage Account V2 and associated features.
491
492- Account name: `devstoreaccount1`
493- Account key: `Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==`
494
495> Note. Besides SharedKey authentication, Azurite V3 supports account, OAuth, and service SAS authentication. Anonymous access is also available when container is set to allow public access.
496
497### Customized Storage Accounts & Keys
498
499As mentioned by above section. Azurite V3 allows customizing storage account names and keys by providing environment variable `AZURITE_ACCOUNTS` with format `account1:key1[:key2];account2:key1[:key2];...`.
500
501For example, customize one storage account which has only one key:
502
503```cmd
504set AZURITE_ACCOUNTS="account1:key1"
505```
506
507Or customize multi storage accounts and each has 2 keys:
508
509```cmd
510set AZURITE_ACCOUNTS="account1:key1:key2;account2:key1:key2"
511```
512
513### Connection Strings
514
515#### HTTP Connection Strings
516
517You can pass the following connection strings to the [Azure SDKs](https://aka.ms/azsdk) or tools (like Azure CLI 2.0 or Storage Explorer)
518
519The full connection string is:
520
521```bash
522DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;
523```
524
525Take blob service only, the full connection string is:
526
527```bash
528DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;
529```
530
531Or if the SDK or tools support following short connection string:
532
533```bash
534UseDevelopmentStorage=true;
535```
536
537#### HTTPS Connection Strings
538
539The full HTTPS connection string is:
540
541```bash
542DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=https://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=https://127.0.0.1:10001/devstoreaccount1;
543```
544
545To use the Blob service only, the HTTPS connection string is:
546
547```bash
548DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=https://127.0.0.1:10000/devstoreaccount1;
549```
550
551If you used `dotnet dev-certs` to generate your self-signed certificate, then you need to use the following connection string, because that only generates a cert for `localhost`, not `127.0.0.1`.
552
553```bash
554DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=https://localhost:10000/devstoreaccount1;QueueEndpoint=https://localhost:10001/devstoreaccount1;
555```
556
557### Azure SDKs
558
559To use Azurite with the [Azure SDKs](https://aka.ms/azsdk), you must use OAuth and HTTPs options:
560
561`azurite --oauth basic --cert certname.pem --key certname-key.pem`
562
563#### Azure Blob Storage
564
565You can then instantiate BlobContainerClient, BlobServiceClient, or BlobClient.
566
567```csharp
568// With container url and DefaultAzureCredential
569var client = new BlobContainerCLient(new Uri("https://127.0.0.1:10000/devstoreaccount1/container-name"), new DefaultAzureCredential());
570
571// With connection string
572var client = new BlobContainerClient("DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=https://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=https://127.0.0.1:10001/devstoreaccount1;", "container-name");
573
574// With account name and key
575var client = new BlobContainerClient(new Uri("https://127.0.0.1:10000/devstoreaccount1/container-name"), new StorageSharedKeyCredential("devstoreaccount1", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="));
576```
577
578#### Azure Queue Storage
579
580You can also instantiate QueueClient or QueueServiceClient.
581
582```csharp
583// With queue url and DefaultAzureCredential
584var client = new QueueCLient(new Uri("https://127.0.0.1:10001/devstoreaccount1/queue-name"), new DefaultAzureCredential());
585
586// With connection string
587var client = new QueueClient("DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=https://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=https://127.0.0.1:10001/devstoreaccount1;", "queue-name");
588
589// With account name and key
590var client = new QueueClient(new Uri("https://127.0.0.1:10001/devstoreaccount1/queue-name"), new StorageSharedKeyCredential("devstoreaccount1", "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="));
591```
592
593### Storage Explorer
594
595#### Storage Explorer with Azurite HTTP
596
597Connect to Azurite by click "Add Account" icon, then select "Attach to a local emulator" and click "Connect".
598
599#### Storage Explorer with Azurite HTTPS
600
601By default Storage Explorer will not open an HTTPS endpoint that uses a self-signed certificate. If you are running Azurite with HTTPS, then you are likely using a self-signed certificate. Fortunately, Storage Explorer allows you to import SSL certificates via the Edit -> SSL Certificates -> Import Certificates dialog.
602
603##### Import Certificate to Storage Explorer
604
6051. Find the certificate on your local machine.
606 - **OpenSSL**: You can find the PEM file at the location you created in the [HTTPS Setup](#https-setup) section above.
607 - **mkcert**: You need to import the RootCA.pem file, which can be found by executing this command in the terminal: `mkcert -CAROOT`. For mkcert, you want to import the RootCA.pem file, not the certificate file you created.
608 - **dotnet dev-certs**: Storage Explorer doesn't currently work with certs produced by `dotnet dev-certs`. We are tracking this issue on GitHub here: https://github.com/microsoft/AzureStorageExplorer/issues/2859
6092. Open Storage Explorer -> Edit -> SSL Certificates -> Import Certificates and import your certificate.
610
611If you do not set this, then you will get the following error:
612
613```
614unable to verify the first certificate
615```
616
617or
618
619```
620self signed certificate in chain
621```
622
623##### Add Azurite via HTTPS Connection String
624
625Follow these steps to add Azurite HTTPS to Storage Explorer:
626
6271. Right click on Local & Attached -> Storage Accounts and select "Connect to Azure Storage...".
6282. Select "Use a connection string" and click Next.
6293. Enter a name, i.e Azurite.
6304. Enter the [HTTPS connection string](#https-connection-strings) from the previous section of this document and click Next.
631
632You can now explore the Azurite HTTPS endpoints with Storage Explorer.
633
634## Workspace Structure
635
636Following files or folders may be created when initializing Azurite in selected workspace location.
637
638- `azurite_db_blob.json` Metadata file used by Azurite blob service. (No when starting Azurite against external database)
639- `azurite_db_blob_extent.json` Extent metadata file used by Azurite blob service. (No when starting Azurite against external database)
640- `blobstorage` Persisted bindary data by Azurite blob service.
641- `azurite_db_queue.json` Metadata file used by Azurite queue service. (No when starting Azurite against external database)
642- `azurite_db_queue_extent.json` Extent metadata file used by Azurite queue service. (No when starting Azurite against external database)
643- `queuestorage` Persisted bindary data by Azurite queue service.
644
645> Note. Delete above files and folders and restart Azurite to clean up Azurite. It will remove all data stored in Azurite!!
646
647## Differences between Azurite and Azure Storage
648
649Because Azurite runs as a local instance for persistent data storage, there are differences in functionality between Azurite and an Azure storage account in the cloud.
650
651### Storage Accounts
652
653> Please reach to us or open issues if you need multi storage account support.
654
655Azurite V3 supports a default account as General Storage Account V2 and provides features.
656
657- Account name: `devstoreaccount1`
658- Account key: `Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==`
659
660### Endpoint & Connection URL
661
662The service endpoints for Azurite are different from those of an Azure storage account. The difference is because the local computer does not perform domain name resolution, requiring Azurite endpoints to be local addresses.
663
664When you address a resource in an Azure storage account, use the following scheme. The account name is part of the URI host name, and the resource being addressed is part of the URI path:
665
666```
667<http|https>://<account-name>.<service-name>.core.windows.net/<resource-path>
668```
669
670For example, the following URI is a valid address for a blob in an Azure storage account:
671
672```
673https://myaccount.blob.core.windows.net/mycontainer/myblob.txt
674```
675
676However, because the local computer does not perform 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:
677
678```
679http://<local-machine-address>:<port>/<account-name>/<resource-path>
680```
681
682For example, the following address might be used for accessing a blob in Azurite:
683
684```
685http://127.0.0.1:10000/myaccount/mycontainer/myblob.txt
686```
687
688The service endpoints for Azurite blob service:
689
690```
691http://127.0.0.1:10000/<account-name>/<resource-path>
692```
693
694### Scalability & Performance
695
696> Please reach to us if you have requirements or suggestions for a distributed Azurite implementation or higher performance.
697
698Azurite is not a scalable storage service and does not support many concurrent clients. There is also no performance and TPS guarantee, they highly depend on the environments Azurite has deployed.
699
700### Error Handling
701
702> Please reach to us if you have requirements or suggestions for a specific error handling.
703
704Azurite tries to align with Azure Storage error handling logic, and provides best-efforts alignment based on Azure Storage online documentation. But CANNOT provide 100% alignment, such as error messages (returned in error response body) maybe different (while error status code will align).
705
706### API Version Compatible Strategy
707
708Azurite V3 follows a **Try best to serve** compatible strategy with Azure Storage API versions:
709
710- An Azurite V3 instance has a baseline Azure Storage API version.
711 - A Swagger definition (OpenAPI doc) with the same API version will be used to generate protocol layer APIs and interfaces.
712 - Azurite should implement all the possible features provided in this API service version.
713- If an incoming request has **the same API version** Azurite provides, Azurite should handle the request with parity to Azure Storage.
714- If an incoming request has a **higher API version** than Azurite, Azurite will return a InvalidHeaderValue error for `x-ms-version` (HTTP status code 400 - Bad Request).
715- If an incoming request has a **lower API version** header than Azurite, Azurite will attempt to handle the request with Azurite's baseline API version behavior instead of that specified in the request.
716- Azurite will return API version in response header as the baseline API version
717- SAS accepts pattern from API version 2015-04-05
718
719### RA-GRS
720
721Azurite supports read-access geo-redundant replication (RA-GRS). For storage resources both in the cloud and in the local emulator, you can access the secondary location by appending -secondary to the account name. For example, the following address might be used for accessing a blob using the secondary in Azurite:
722
723```
724http://127.0.0.1:10000/devstoreaccount1-secondary/mycontainer/myblob.txt
725```
726
727> Note. Secondary endpoint is not read-only in Azurite, which diffs from Azure Storage.
728
729## Differences between Azurite V3 and Azurite V2
730
731Both Azurite V3 and Azurite V2 aim to provide a convenient emulation for customers to quickly try out Azure Storage services locally. There are lots of differences between Azurite V3 and legacy Azurite V2.
732
733### Architecture
734
735Architecture in Azurite V3 has been refactored, it's more flexible and robust. It provides the flexibility to support following scenarios in the future:
736
737- Use other HTTP frameworks instead of express.js
738- Customized new handler layer implementation, such as redirecting requests to Azure Storage services
739- Implement and inject a new persistency layer implementation, such as one based on a different database service
740- Provide support for multiple azure storage accounts and authentication
741- Detailed debug logging for easy issue investigation and request tracking
742- Create HTTPS server
743- ...
744
745### Server Code Generator
746
747Azurite V3 leverages a TypeScript server code generator based on Azure Storage REST API swagger specifications. This reduces manual efforts and ensures alignment with the API implementation.
748
749### TypeScript
750
751Azurite V3 selected TypeScript as its' programming language, as this facilitates broad collaboration, whilst also ensuring quality.
752
753### Features Scope
754
755Legacy Azurite V2 supports Azure Storage Blob, Queue and Table services.
756Azurite V3 currently only supports Azure Storage blob service. Queue service is supported after V3.2.0-preview.
757Table service support is currently under discussion.
758
759Azurite V3 supports features from Azure Storage API version 2019-12-12, and will maintain parity with the latest API versions, in a more frequent update frequency than legacy Azurite V2.
760
761## TypeScript Server Code Generator
762
763Azurite V3 leverages a TypeScript Node.js Server Code Generator to generate the majority of code from Azure Storage REST APIs swagger specification.
764Currently, the generator project is private, under development and only used by Azurite V3.
765We have plans to make the TypeScript server generator public after Azurite V3 releases.
766All the generated code is kept in `generated` folder, including the generated middleware, request and response models.
767
768## Support Matrix
769
770Latest release targets **2019-12-12** API version **blob** service.
771Detailed support matrix:
772
773- Supported Vertical Features
774 - CORS and Preflight
775 - SharedKey Authentication
776 - OAuth authentication
777 - Shared Access Signature Account Level
778 - Shared Access Signature Service Level (Not support response header override in service SAS)
779 - Container Public Access
780- Supported REST APIs
781 - List Containers
782 - Set Service Properties
783 - Get Service Properties
784 - Get Stats
785 - Get Account Information
786 - Create Container
787 - Get Container Properties
788 - Get Container Metadata
789 - Set Container Metadata
790 - Get Container ACL
791 - Set Container ACL
792 - Delete Container
793 - Lease Container
794 - List Blobs
795 - Put Blob (Create append blob is not supported)
796 - Get Blob
797 - Get Blob Properties
798 - Set Blob Properties
799 - Get Blob Metadata
800 - Set Blob Metadata
801 - Create Append Blob, Append Block
802 - Lease Blob
803 - Snapshot Blob
804 - Copy Blob (Only supports copy within same account in Azurite)
805 - Abort Copy Blob (Only supports copy within same account in Azurite)
806 - Access control based on conditional headers
807- Following features or REST APIs are NOT supported or limited supported in this release (will support more features per customers feedback in future releases)
808
809 - SharedKey Lite
810 - Static Website
811 - Soft delete & Undelete Blob
812 - Put Block from URL
813 - Incremental Copy Blob
814 - Blob Tags
815 - Blob Query
816 - Blob Versions
817
818Latest version supports for **2019-12-12** API version **queue** service.
819Detailed support matrix:
820
821- Supported Vertical Features
822 - SharedKey Authentication
823 - Shared Access Signature Account Level
824 - Shared Access Signature Service Level
825 - OAuth authentication
826- Supported REST APIs
827 - List Queues
828 - Set Service Properties
829 - Get Service Properties
830 - Get Stats
831 - Preflight Queue Request
832 - Create Queue
833 - Get Queue Metadata
834 - Set Queue Metadata
835 - Get Queue ACL
836 - Set Queue ACL
837 - Delete Queue
838 - Put Message
839 - Get Messages
840 - Peek Messages
841 - Delete Message
842 - Update Message
843 - Clear Message
844- Following features or REST APIs are NOT supported or limited supported in this release (will support more features per customers feedback in future releases)
845 - SharedKey Lite
846
847## License
848
849This project is licensed under MIT.
850
851## We Welcome Contributions!
852
853> Go to [GitHub project](https://github.com/Azure/Azurite/projects) page or [GitHub issues](https://github.com/Azure/Azurite/issues) for the milestone and TODO items we are used for tracking upcoming features and bug fixes.
854
855We are currently working on Azurite V3 to implement the remaining Azure Storage REST APIs.
856We finished the basic structure and majority of features in Blob Storage, as can be seen in the support matrix.
857The detailed work items are also tracked in GitHub repository projects and issues.
858
859Any contribution and suggestions for Azurite V3 is welcome, please goto `CONTRIBUTION.md` for detailed contribution guidelines. Alternatively, you can open GitHub issues voting for any missing features in Azurite V3.
860
861Most contributions require you to agree to a
862Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
863the rights to use your contribution. For details, visit <https://cla.microsoft.com.>
864
865When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
866a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
867provided by the bot. You will only need to do this once across all repos using our CLA.
868
869This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
870For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
871contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.