Files
azure-storage-emulator/README.md

105 lines
2.6 KiB
Markdown

# Azure Storage Emulator
This is a simple guide that will help you set up and run the Azure Storage Emulator on your local machine. The Azure Storage Emulator allows you to develop and test your applications that use Azure Storage services without needing an actual Azure subscription nor Internet connection.
Review the [Documentation](#reference) for more details on how to use the emulator and its features. This document will cover a scenario where you want to run the emulator as close to the real Azure Storage service as possible, which means using triple HTTPS endpoints and OAuth simulation.
## Docker Installation
To run the Azure Storage Emulator in a Docker container, follow these steps:
1. Ensure that a container runtime is installed. This repository supports both Docker and Apple `container` command.
2. Build the emulator image using the provided Dockerfile:
```bash
./build.sh
```
3. Run the emulator container:
```bash
./run.sh
```
## Native Installation
To install the Azure Storage Emulator natively on your machine, follow these steps:
1. Clone the repository:
```bash
git clone https://github.com/azure/azurite
```
2. Navigate to the cloned directory:
```bash
cd azurite
```
3. Build the emulator package.
```bash
npm ci
npm run build
npm pack
```
4. Install the package globally using npm:
```bash
npm install -g azurite-*.tgz
```
5. Remove the clone directory, it will not be needed anymore:
```bash
cd ..
rm -rf azurite
```
6. Install the Caddy HTTP server.
7. Create an `accounts.env` file in the same directory as the `run-server.sh` script with the following content:
```bash
AZURITE_ACCOUNTS=accountname:accountkey
```
Replace `accountname` with the desired account name. Use OpenSSL to generate an account key.
```bash
openssl rand -base64 32
```
You can also generate a deterministic account key using any string as a seed:
```bash
echo -n "your-seed-string" | base64
```
8. Add the following line to your `/etc/hosts` file to map the custom domain names to localhost:
```
127.0.0.1 <accountname>.blob.core.windows.net <accountname>.queue.core.windows.net <accountname>.table.core.windows.net
```
9. Run the server:
```bash
./run-server.sh
```
You can add the `--oauth` or `-o` flag to simulate OAuth authentication.
```bash
./run-server.sh --oauth
```
## Reference
- [Azure Storage Emulator GitHub Repository](https://github.com/azure/azurite)
- [Azure Storage Emulator Documentation](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite)
- [Caddy Server](https://caddyserver.com)