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.

Prerequisites

  • Any system that supports fairly recent versions of Node.js (LTS vesions are recommended).
  • A Bash shell (a Linux or macOS system or Windows with WSL2 installed).
  • Docker Community Edition or Docker Desktop (for running the emulator in a containerized environment).
  • Apple container command (for running the containerized version of the emulator on macOS).

Native Installation

To install the Azure Storage Emulator natively on your machine, follow these steps:

  1. Clone the repository:

    git clone https://github.com/azure/azurite
    
  2. Navigate to the cloned directory:

    cd azurite
    
  3. Build the emulator package.

    npm ci
    npm run build
    npm pack
    
  4. Install the package globally using npm:

    npm install -g azurite-*.tgz
    
  5. Remove the clone directory, it will not be needed anymore:

    cd ..
    rm -rf azurite
    

Running the Emulator

There are two ways to run the Azure Storage Emulator: as a development server exposing the API on localhost using high ports (10000-10002) or as a fake Azure Storage service. The first one is easy, just run the azurite command in your terminal and that's it. The second one is a bit more complex, but it allows you to use the emulator as if it were the real Azure Storage service, and connect to it applications that do not support custom endpoints (Terraform azurerm state storage backend for example).

Run the make-certs.sh script to generate a self-signed CA certificate and a server certificate signed by that CA. The server certificate will be used by the emulator to serve HTTPS traffic, and the CA certificate can be imported into your system's trusted root certificates store to avoid security warnings when connecting to the emulator.

The make-certs.sh script will create a storage directory for the emulator and place the generated PEM files there. The script will create a certificate for the terraform.blob.core.windows.net. You can change that. You will also need to map that name to 127.0.0.1 in your hosts file.

127.0.0.1 terraform.blob.core.windows.net

Next, create an empty accounts.env file in the same directory. This file will be used by the emulator to retrieve the storage accounts names and access keys. You can use a single key or a pair of keys for each account. The format of the file is as follows:

AZURITE_ACCOUNTS="account1:key1,key2;account2:key1,key2;..."

Use add-account.sh script to add at least one account to the accounts.env file. The script will generate random key for each added account. You can use list-accounts.sh script to list all accounts and their keys. You can also specify a password that will be used as the value for the key. The key is always Base64 encoded, and you password will also be Base64 encoded before being stored in the accounts.env file. The benefit of using a password is that the account key will be deterministic, so you can easily recreate the same account with the same key if needed.

Finally, run the emulator using the run-emulator.sh script.

Description
No description provided
Readme MIT 140 KiB
Languages
Shell 91.8%
Dockerfile 5%
HCL 3.2%