skip to Main Content

How can I run unit tests which require Azure Storage Emulator in the Azure Pipelines?
I have been going back and forward with this for days now and I have no idea what I’m missing, my agent uses the Windows-2022 image and according to the documentation it doesn’t have the Azure Storage Emulator anymore, so I’m downloading and running Azurite in the process as a background job (so the pipeline wouldn’t hang).

However, when I get to my unit tests, the connection is refused by Azure, I can’t find anything about why this could be happening.

Did anyone face this issue before and was able to solve it?

Just as a side note, the unit tests run fine locally and so does the emulator, below are a few screenshots from my pipeline.

The pipeline
enter image description here

Install and run Azurite script

enter image description here

2

Answers


  1. It might be due to the Storage Emulator, so check the status by going to:

    Program Files (x86)Microsoft SDKsAzureStorage Emulator
    

    Run the following command-line syntax:

    AzureStorageEmulator.exe status
    

    Prints the status of the Storage Emulator. If it’s not running do the following in order:

    AzureStorageEmulator.exe init
    AzureStorageEmulator.exe stop
    AzureStorageEmulator.exe clear all
    AzureStorageEmulator.exe start
    

    OR run the following Batch Script which will clean it, and start it up:

    SET emulator="%programfiles(x86)%Microsoft SDKsAzureStorage EmulatorAzureStorageEmulator.exe"
    %emulator% stop
    %emulator% clear all
    %emulator% start
    

    Updated Answer, since the above applies only to the Legacy Azure Storage Emulator see the following suggestion. In your case is most likely the port and since you mention is a shared environment, it might be in use by another process. Seems like it truncates on the Queue Service (10001). You should eliminate a port misconfiguration. Define another --queuePort or, let the system auto select an available port by running the following in console:

    azurite --queuePort 0
    
    Login or Signup to reply.
  2. Try using the bash task (instead of Powershell) for installing and running the azurite. That works for me…

    enter image description here

    Inline script

    echo "Installing azurite"
    npm install -g azurite
    mkdir azurite
    echo "azurite installed"
    azurite --silent --location azurite --debug azuritedebug.txt --queuePort 10001 &
    echo "azurite started"
    sleep 5
    

    The raw log

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search