Running Azure Storage in Windows Server Container Emulator (iii): Running in a container

Source: Internet
Author: User

In the previous section, we've got SQL Server ready, so next, we're going to put the ASE in the container.

First, create a new START.PS1 with the following content:

1 param(2[Parameter (mandatory=$true)][string]$HostName,3[String]$AccountName,4[String]$AuthKey,5[String]$SqlServerInstance)6 7 #Initialized?8 if(test-Path Initialized)9 {Ten&"C:\Program Files (x86) \microsoft Sdks\azure\storage Emulator\azurestorageemulator.exe"Start-inporcess One } A  - if([String]::isnullorempty ($AccountName)) - { theWrite-output"accountname argument not specified, use the Default:devstoreaccount1" -     $AccountName="Devstoreaccount1" - } - if([String]::isnullorempty ($AuthKey)) + { -Write-output"AuthKey argument not specified, use the default:eby8vdm02xnocqflquwjpllmetlcdxj1ouzft50usrz6ifsufq2uvercz4i6tq/ k1szfptotr/kbhbeksogmgw==" +     $AuthKey="eby8vdm02xnocqflquwjpllmetlcdxj1ouzft50usrz6ifsufq2uvercz4i6tq/k1szfptotr/kbhbeksogmgw==" A } at if([String]::isnullorempty ($SqlServerInstance)) - { -Write-output"sqlserverinstance argument not specified, use the default: (LOCALDB) \mssqllocaldb" -     $SqlServerInstance="(localdb) \mssqllocaldb" - } -  in #Replace the configuration - $config="C:\Program Files (x86) \microsoft Sdks\azure\storage Emulator\azurestorageemulator.exe.config" to(get-content$config)` +     -replace "<service name=""Blob""url=""http://127.0.0.1:10000/""/>","<service name=""Blob""url=""http://$AccountName. Blob. $HostName/""/>"` -     -replace "<service name=""Queue""url=""http://127.0.0.1:10001/""/>","<service name=""Queue""url=""http://$AccountName. Queue. $HostName/""/>"` the     -replace"<service name=""Table""url=""http://127.0.0.1:10002/""/>","<service name=""Table""url=""http://$AccountName. Table. $HostName/""/>"` *     -replace "<account name=""Devstoreaccount1""authkey=""eby8vdm02xnocqflquwjpllmetlcdxj1ouzft50usrz6ifsufq2uvercz4i6tq/k1szfptotr/kbhbeksogmgw==""/>",` $         "<account name=""$AccountName""authkey=""$AuthKey""/>"`Panax Notoginseng| Out-file $config -  the #Init the emulator +&"C:\Program Files (x86) \microsoft Sdks\azure\storage Emulator\azurestorageemulator.exe"Init-server$SqlServerInstance A  the #Set Initialized Flag +new-Item Initialized -  $ #start! $&"C:\Program Files (x86) \microsoft Sdks\azure\storage Emulator\azurestorageemulator.exe"Start-inprocess

Dockerfile:

# escape= '  from Microsoft/windowsservercore ADD https://go.microsoft.com/fwlink/?linkid=717179&clcid=0x409 microsoftazurestorageemulator.msi RUN msiexec/q /I Microsoftazurestorageemulator.msi RUN del Microsoftazurestorageemulator.msi COPY start.ps1. # Azure Storage Emulator EXPOSE # Configure and launchentrypoint PowerShell. \start.ps1

Maybe it's a good idea to put AzureStorageEmulator.exe "Init in Dockerfile, but it's not what I want for each environment to build a different image."

Now it's time to Build our image:

Docker build-t Charmsan/azurestorageemulator.

In order to run the container using GMSA, there is one more step (using GMSA in the container, see my other blog post: Using GMSA in Windows containers):

New-credentialspec-name Asesvc-accountname Asesvc

launch!

" Credentialspec=file://asesvc.json " --restart unless-stopped charmsan/azurestorageemulator-hostname contoso.com-accountname Dev- Sqlserverinstance Contoso-env-db\contoso_dev

Operation Result:

Please ignore the two errors inside and configure the Azure Storage Explorer connection:

Operation Result:

Now, we can modify the Web.Debug.config to transform the connection string:

    <xdt:transform= "SetAttributes"  xdt:locator= "Match (key)" Key = "Storageaccountconnectionstring" value = "defaultendpointsprotocol=http; Accountname=dev; accountkey=eby8vdm02xnocqflquwjpllmetlcdxj1ouzft50usrz6ifsufq2uvercz4i6tq/k1szfptotr/kbhbeksogmgw==; Blobendpoint=http://dev.blob.contoso.com/dev; " />

Don't ask me what the URL in the connection string is like, because you're definitely not looking at the first verse:)

Running Azure Storage in Windows Server Container Emulator (iii): Running in a container

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.