Using Azure CLI with local storage emulator
Tags: azcli, azure, azurestorage, emulator
Published: 2019-12-02 04:31:04

---
title: Using Azure CLI with local storage emulator
published: true
description: Sometimes, we just have go local with development, that is not just food. This article is about how to configure your Azure CLI to go with your local storage emulator.
tags: az-cli, azure, azure-storage, emulator
---

#The Beginnings - Unusual Circumstances

While working with a fellow engineer who uses virtualized Linux machine as their primary development environment on Windows 10 PC hosted on Virtual Box, we ran into challenges with accessing the Azure local storage emulator - [Azurite](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite), with the [Azure Storage Explorer] (https://azure.microsoft.com/en-us/features/storage-explorer/). 

The root cause was the corporate proxy settings associated with the laptop that we **just** could not to resolve. 

A mighty unusual start in a way, but that is hand we were dealt.  

#Finding the path forward
Our project involved developing Azure Functions using Python, which was dependent on use of Azure Storage Queues and access to local development was critical for developer isolation and productivity. But using Storage Explorer became an issue, we were left few options. 

First one, drop Linux as our development environment and move to Windows or  MacOS, which did not seem to have this issue. Ugly, huh? It also flies right in the face of cross-platform development.

Second one, living the hashtag - #WeAreDevelopers, write some test harness/setup code using the Azure Python SDK and keep it up to date. It was an option, not the most efficient one.


#The Middle Ground - Hacked it! or really on shoulder of giants

[Azure CLI](https://docs.microsoft.com/en-us/cli/azure/?view=azure-cli-latest) is a cross platform development for developers and administrators to interact with the Azure Cloud. And until now that is how I had been using Azure CLI, to work with Azure Cloud and not for local development.

So **what if**, there is a way to use the Azure CLI storage command to work with local storage versus working with Cloud Storage??? 

IF Only, **What IF??**

As it turns out, **THERE IS**. Though not as well documented (as in here in your face... *DOCUMENTED*), it is possible to stitch the solution using the documentation for [Azure Storage Emulator](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator) and [Configuration for Azure CLI](https://docs.microsoft.com/en-us/cli/azure/azure-cli-configuration?view=azure-cli-latest).

#The solution

It turns out to be as simple as setting the value a environment variable -  _AZURE_STORAGE_CONNECTION_STRING_, which becomes the default connection string that Azure CLI uses, if a storage account is not specified.

Here is the command to run:

``` bash

$ AZURE_STORAGE_CONNECTION_STRING="UseDevelopmentStorage=true"
$ export AZURE_STORAGE_CONNECTION_STRING
$ az storage queue create -n myqueue
{
   "created" : true
}

$ az storage queue create -n anotherqueue
{
   "created" : true
}


$ az storage queue create -n newqueue
{
   "created" : true
}


$ az storage queue list --verbose


```

#The Conclusion

Unfortunately, the firewall issues with the corporate laptop still persisted even with this. This approach **did not solve** the original problem. 

But this unusual set of circumstances led me to discover a new way to use Azure CLI. For example - I can use it to test setup scripts, offline for Azure Storage.

So, today as I write this, I am living the motto of my group within Microsoft - _"We reserve the right to become smarter"_.

So my fellow developers - keep hacking and be UNSTOPPABLE!