title: Windows Service in Azure Container Will Not Start
body: <p>I am working on a POC to run a windows service in a Azure Container Instance. I have created docker containers that run our service based on windows:1809 and servercore:ltsc2019. When I run the image locally using docker the service starts and runs correctly. I am running the container locally using hyper-v isolation. I have uploaded the images to my Azure container Registry and created an instances of them yet when I start the container the service will not start. The service is installed but not in a running state.</p>
  
  <p>The service is installed and should be started with the container starts.</p>
  
  <pre><code>PS C:\&gt; Get-Service My*
  Status   Name               DisplayName
  ------   ----               -----------
  Stopped  MyService      My Service
  </code></pre>
  
  <p>If I attempt to start the service from the command line I get this error:</p>
  
  <pre><code>PS C:\&gt; Start-Service MyService
  Start-Service : Service 'My Service (MyService)' cannot be
  started due to the following error: Cannot start service MyService on
  computer '.'.
  At line:1 char:1
  + Start-Service MyService
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : OpenError: (System.ServiceProcess.ServiceControl
     ler:ServiceController) [Start-Service], ServiceCommandException
      + FullyQualifiedErrorId : CouldNotStartService,Microsoft.PowerShell.Comman
     ds.StartServiceCommand
  </code></pre>
  
  <p>If I use net command I get the following:</p>
  
  <pre><code>PS C:\&gt; net start MyService
  The service is not responding to the control function.
  </code></pre>
  
  <p>The event log has a 1053 error with the message that the timeout was reached after 30 seconds. I ran the start-service from the command line and the log entry did not take 30 seconds to be entered, it is added almost immediatly. I have run the start command using ContainerAdministrator, then added ContainerAdministrator to the local Administrators, and ran a powershell session as a different local administrator to the same results.</p>
  
  <p>Here is the event log:</p>
  
  <pre><code>PS C:\&gt; $A = Get-EventLog -LogName system -Newest 7
  PS C:\&gt; $A | Select-Object -Property *
  EventID            : 7000
  MachineName        : wk-caas-28c951151b41452385daba69f308873d-bd43b2406c94ac918
                       8077a
  Data               : {80, 0, 51, 0...}
  Index              : 1126
  Category           : (0)
  CategoryNumber     : 0
  EntryType          : Error
  Message            : The My Service service failed to start due
                       to the following error:
                       %%1053
  Source             : Service Control Manager
  ReplacementStrings : {My Service, %%1053}
  InstanceId         : 3221232472
  TimeGenerated      : 4/16/2020 8:46:09 PM
  TimeWritten        : 4/16/2020 8:46:09 PM
  UserName           :
  Site               :
  Container          :
  
  EventID            : 7009
  MachineName        : wk-caas-28c951151b41452385daba69f308873d-bd43b2406c94ac918
                       8077a
  Data               : {80, 0, 51, 0...}
  Index              : 1125
  Category           : (0)
  CategoryNumber     : 0
  EntryType          : Error
  Message            : A timeout was reached (30000 milliseconds) while waiting
                       for the My Service service to connect.
  Source             : Service Control Manager
  ReplacementStrings : {30000, My Service}
  InstanceId         : 3221232481
  CimeGenerated      : 4/16/2020 8:46:09 PM
  TimeWritten        : 4/16/2020 8:46:09 PM
  UserName           :
  Site               :
  Container          :
  </code></pre>
  
  <p>I am new to docker, containers, and Azure and cannot find a reason why my service would not respond in a timely manner or why the log entry would be added in less than the 30 seconds the log reports, any ideas would be greatly appreciated.</p>