├── entrypoint.cmd ├── nginx.conf ├── LICENSE ├── README.md └── Dockerfile /entrypoint.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | AzureStorageEmulator.exe start 4 | 5 | 6 | call %* -------------------------------------------------------------------------------- /nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes 1; 2 | 3 | error_log stderr; 4 | 5 | events { 6 | worker_connections 1024; 7 | } 8 | 9 | http { 10 | client_max_body_size 0; # Remove body size limit 11 | proxy_http_version 1.1; 12 | access_log off; # find way to redirect log to stdout on winodws 13 | 14 | server { 15 | listen 10000; 16 | server_name localhost; 17 | 18 | location / { 19 | proxy_pass http://127.0.0.1:20000; 20 | } 21 | } 22 | 23 | server { 24 | listen 10001; 25 | server_name localhost; 26 | 27 | location / { 28 | proxy_pass http://127.0.0.1:20001; 29 | } 30 | } 31 | 32 | server { 33 | listen 10002; 34 | server_name localhost; 35 | 36 | location / { 37 | proxy_pass http://127.0.0.1:20002; 38 | } 39 | } 40 | } 41 | 42 | daemon off; 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Boshi Lian 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Azure Storage Emulator Docker Image 2 | 3 | 4 | [![Build status](https://dev.azure.com/farmer1992/opensources/_apis/build/status/DockerBuild-AzureStorageEmulator)](https://dev.azure.com/farmer1992/opensources/_build/latest?definitionId=9) 5 | 6 | ## Microsoft Docker hub verison 7 | 8 | please use `farmer1992/azure-storage-emulator` instead of `microsoft/azure-storage-emulator` 9 | MS repo are moving to a new project . thus, the old .net version was freezed. 10 | 11 | ## Usage 12 | 13 | ``` 14 | docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 farmer1992/azure-storage-emulator 15 | ``` 16 | 17 | ### You may want C# code to generate connection string 18 | 19 | _Note:_ No need to modify the secret, it was hardcoded in container. 20 | 21 | Raw string 22 | ``` 23 | DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1; 24 | ``` 25 | 26 | C# 27 | 28 | ``` 29 | static string GenerateConnStr(string ip = "127.0.0.1", int blobport = 10000, int queueport = 10001, int tableport = 10002) 30 | { 31 | return $"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://{ip}:{blobport}/devstoreaccount1;TableEndpoint=http://{ip}:{tableport}/devstoreaccount1;QueueEndpoint=http://{ip}:{queueport}/devstoreaccount1;"; 32 | } 33 | ``` 34 | 35 | Connect to emulator 36 | 37 | ``` 38 | var cloudStorageAccount = CloudStorageAccount.Parse(GenerateConnStr()); 39 | 40 | // ... 41 | ``` 42 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/servercore:ltsc2016 2 | MAINTAINER Boshi Lian 3 | 4 | ENV LOCAL_DB_URL https://download.microsoft.com/download/9/0/7/907AD35F-9F9C-43A5-9789-52470555DB90/ENU/SqlLocalDB.msi 5 | RUN powershell -NoProfile -Command \ 6 | Invoke-WebRequest %LOCAL_DB_URL% -OutFile SqlLocalDB.msi; 7 | 8 | RUN msiexec /i SqlLocalDB.msi /qn /norestart IACCEPTSQLLOCALDBLICENSETERMS=YES 9 | 10 | ENV AZ_STOR_EMU_URL https://download.visualstudio.microsoft.com/download/pr/87453e3b-79ac-4d29-a70e-2a37d39f2b12/f0e339a0a189a0d315f75a72f0c9bd5e/microsoftazurestorageemulator.msi 11 | 12 | RUN powershell -NoProfile -Command \ 13 | Invoke-WebRequest %AZ_STOR_EMU_URL% -OutFile MicrosoftAzureStorageEmulator.msi; 14 | 15 | RUN msiexec /i MicrosoftAzureStorageEmulator.msi /qn 16 | 17 | RUN powershell -NoProfile -Command \ 18 | Remove-Item -Force *.msi; 19 | 20 | 21 | RUN setx /M AZ_STOR_EMU_HOME "%ProgramFiles(x86)%\Microsoft SDKs\Azure\Storage Emulator" 22 | RUN setx /M PATH "%PATH%;%AZ_STOR_EMU_HOME%" 23 | 24 | WORKDIR "C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator" 25 | 26 | # have to use nginx as reverse proxy, or 400 bad hostname 27 | #RUN powershell -NoProfile -Command \ 28 | # "(Get-Content .\AzureStorageEmulator.exe.config) -replace 'http://127.0.0.1','http://localhost' | Out-File -Encoding utf8 .\AzureStorageEmulator.exe.config" 29 | 30 | RUN powershell -NoProfile -Command \ 31 | "(Get-Content .\AzureStorageEmulator.exe.config) -replace 'http://127.0.0.1:10000/','http://127.0.0.1:20000/' | Out-File -Encoding utf8 .\AzureStorageEmulator.exe.config"; \ 32 | "(Get-Content .\AzureStorageEmulator.exe.config) -replace 'http://127.0.0.1:10001/','http://127.0.0.1:20001/' | Out-File -Encoding utf8 .\AzureStorageEmulator.exe.config"; \ 33 | "(Get-Content .\AzureStorageEmulator.exe.config) -replace 'http://127.0.0.1:10002/','http://127.0.0.1:20002/' | Out-File -Encoding utf8 .\AzureStorageEmulator.exe.config"; 34 | 35 | ADD entrypoint.cmd 'C:\entrypoint.cmd' 36 | 37 | RUN AzureStorageEmulator.exe init 38 | 39 | WORKDIR "C:\nginx" 40 | 41 | ENV NGX_URL https://nginx.org/download/nginx-1.12.0.zip 42 | RUN powershell -NoProfile -Command \ 43 | Invoke-WebRequest %NGX_URL% -OutFile nginx.zip; \ 44 | Expand-Archive nginx.zip . ; 45 | 46 | RUN powershell -NoProfile -Command \ 47 | Copy-Item nginx-*\*.exe . ; \ 48 | Remove-Item -Recurse nginx-* ; \ 49 | Remove-Item -Force nginx.zip; 50 | 51 | RUN powershell -NoProfile -Command \ 52 | mkdir logs ; \ 53 | mkdir temp ; 54 | 55 | ADD nginx.conf 'conf\nginx.conf' 56 | 57 | EXPOSE 10000 10001 10002 58 | 59 | ENTRYPOINT C:\entrypoint.cmd 60 | CMD nginx.exe 61 | 62 | 63 | --------------------------------------------------------------------------------