title: Role in Azure Compute Emulator stuck cycling between Unknown and Destroyed states
body: <p>My Azure Cloud Service's Web Role works fine when deployed to Azure but can't get it running with the Emulator.</p>
  
  <ul>
  <li>When starting the role from within Visual Studio (2015) the window just displays "Starting the roles for the application in the Microsoft Azure compute emulator...".</li>
  <li>When starting with the debugger <code>OnStart()</code> doesn't seem to be hit at all, so something before that gets stuck. The role doesn't seem to be started because the app's custom logs are not created either.</li>
  <li>Looking at the Compute Emulator's UI reveals that the role is continuously (and very slowly) cycling between Unknown and Destroyed states. </li>
  <li>There seems to be nothing relevant logged to the Event Logs (see <a href="https://stackoverflow.com/a/40855089/220230">this answer</a>) apart from messages about SSL certificates being added for the HTTPS endpoints (see below)</li>
  </ul>
  
  <p>Any idea where can I look for clues on what makes the role stuck?</p>
  
  <p>The Output window in VS has this as the last message:</p>
  
  <pre><code>Microsoft Azure Tools: Warning: Attempting to bind SSL Certificate with identity sha1:something for endpoint named HTTPS of role RoleName.
  </code></pre>
  
  <p>The role has some SSL certificates defined as well as an HTTP and two HTTPS endpoints. However removing these didn't seem to solve the problem, then it gets stuck on this (added automatically because RDP access is enabled):</p>
  
  <pre><code>Microsoft Azure Tools: Warning: Certificate identification setting 'Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption' for role 'RoleName' specified in the service configuration file is not declared in the service definition file in the Certificate or as part of an SSL endpont
  </code></pre>
  
  <p>(Notice the typo at the end :-).)</p>
  
  <p>I've taken a look at the logs under C:\Users\Me\AppData\Local\dftmp. The logs and EmulatorRuntimeLogs folders are empty, DFAgentLogs\DFAgent.log contains some entries, this is what gets repeated:</p>
  
  <blockquote>
    <p>[2017/01/29, 21:27:55.532, ERROR, 00019400] &lt;- RuntimeRole::CreateRoleProcess(0x00000224DE6EA670) =0x80070057
    [2017/01/29, 21:27:55.644, ERROR, 00019400] &lt;- RuntimeRole::StartRoleProcess(0x00000224DE6EA670) =0x80070057
    [2017/01/29, 21:27:55.748, ERROR, 00019400] &lt;- RuntimeRole::LaunchDevExRoleHost(0x00000224DE6EA670) =0x80070057
    [2017/01/29, 21:27:55.838, ERROR, 00019400] &lt;- RuntimeRole::StartUnsafe(0x00000224DE6EA670) =0x80070057
    [2017/01/29, 21:27:55.922, ERROR, 00019400] &lt;- RuntimeRole::Start(0x00000224DE6EA670) =0x80070057
    [2017/01/29, 21:27:56.021, ERROR, 00019400] &lt;- RuntimeBaseContainer::StartRole_Unsafe(0x00000224DE681BE0) =0x80070057
    [2017/01/29, 21:27:56.055, ERROR, 00019400] &lt;- RuntimeBaseContainer::StartRole(0x00000224DE681BE0) =0x80070057
    [2017/01/29, 21:27:56.079, ERROR, 00019400] &lt;- RuntimeStartRole=0x80070057
    [2017/01/29, 21:27:56.110,  INFO, 00019400] StartRoleResult deployment29(73).RoleName_IN_0, 80070057
    [2017/01/29, 21:27:56.110,  INFO, 00019400] Got Notify
    [2017/01/29, 21:27:56.110,  INFO, 00019400] DestroyRoleConfigResources: RoleName_IN_0:0:cb0b9125-93b1-43e7-9780-f5c6a15f435a
    [2017/01/29, 21:27:56.110,  INFO, 00019400] Got Notify
    [2017/01/29, 21:27:56.110,  INFO, 00019400] StartRoleWorker returned 0x80070057
    [2017/01/29, 21:27:56.114,  INFO, 00013244] Called GetState
    [2017/01/29, 21:27:56.114,  INFO, 00013244] There are 3 notifications.
    [2017/01/29, 21:27:56.114,  INFO, 00013244] Role notifications 0, Instance: RoleName_IN_0:0:cb0b9125-93b1-43e7-9780-f5c6a15f435a State: 2
    [2017/01/29, 21:27:56.114,  INFO, 00013244] Role notifications 1, Instance: RoleName_IN_0:0:cb0b9125-93b1-43e7-9780-f5c6a15f435a State: 10
    [2017/01/29, 21:27:56.114,  INFO, 00013244] Role notifications 2, Instance: RoleName_IN_0:0:cb0b9125-93b1-43e7-9780-f5c6a15f435a State: 11
    [2017/01/29, 21:27:56.114,  INFO, 00013244] There are 1 completion events.
    [2017/01/29, 21:27:56.114,  INFO, 00013244] CompletionEvent 0, Type: StartRoleCompleted Id: deployment29(73).RoleName_IN_0 Status: 0x2147942487
    [2017/01/29, 21:27:56.114,  INFO, 00013244] GetState returned.
    [2017/01/29, 21:27:56.115,  INFO, 00015700] Called AcknowledgeNotifications
    [2017/01/29, 21:27:56.115,  INFO, 00015700] Cleanup the notifications and completion events, last sequence = 3317
    [2017/01/29, 21:27:56.115,  INFO, 00013244] Called StartRole
    [2017/01/29, 21:27:56.115,  INFO, 00013244] StartRole returned. 
    [2017/01/29, 21:27:56.115,  INFO, 00019400] StartRoleWorker, instance = deployment29(73).RoleName_IN_0
    [2017/01/29, 21:27:56.116,  WARN, 00019400] Role deployment29(73).RoleName_IN_0 not found.
    [2017/01/29, 21:27:56.116, ERROR, 00019400] &lt;- RuntimeContainer::FindRoleUnsafe=0x80070490
    [2017/01/29, 21:27:56.135,  INFO, 00019400] SetupRoleConfigResources: RoleName_IN_0:0:cb0b9125-93b1-43e7-9780-f5c6a15f435a
    [2017/01/29, 21:27:56.136,  INFO, 00019400] Got Notify
    [2017/01/29, 21:27:56.136,  INFO, 00019400] Starting Role
    [2017/01/29, 21:27:56.140,  INFO, 00019400] Runtime Server Named Pipe Name =  \.\pipe\RdRuntimeServer.
    [2017/01/29, 21:27:56.140,  INFO, 00019400] Runtime Server Named Pipe Timeout Time =  30.
    [2017/01/29, 21:27:56.140, ERROR, 00019400] Failed to create process "path\to\role\project's\folder\csx\Debug\roles\Lombiq.Hosting.RequestRouter.RouterRole\base\x64\WaHostBootstrapper.exe" base\x64\WaIISHost.exe .</p>
  </blockquote>
  
  <p>However I have no idea why the process couldn't be created (the file is there; although my username has an accented character in it and thus in the path, it didn't help to move the folder to the drive root) and there seems to be no other information anywhere. The Storage and Compute Emulator otherwise starts and works.</p>
  
  <p>These didn't help:</p>
  
  <ul>
  <li>Running VS as administrator.</li>
  <li>Separately pre-starting the Compute Emulator as an administrator.</li>
  <li>Checking if it has to do something with the user account: It also works on another machine on mine, which has the same Windows user account.</li>
  <li>Disabling Windows firewall.</li>
  <li>Updating the Azure SDK from 2.9 to 3.0.</li>
  <li>Updating the role's (Azure-related) NuGet packages to latest.</li>
  <li>Repairing the VS installation.</li>
  </ul>
  
  <p>The same solution works on one of my colleague's machine, so it should be some issue with my machine, and this specific one.</p>
  
  <p>I also tried this with an empty Cloud Service project with an empty ASP.NET role and the same happens.</p>
  
  <p>A similar question: <a href="https://stackoverflow.com/questions/35831063/azure-emulator-appears-to-hanging-on-web-role-startup">Azure Emulator appears to Hanging on Web Role startup</a>.</p>
  
  <p><strong>Update, getting closer:</strong></p>
  
  <p>I'm also getting these in the Event Log under Windows Logs/System:</p>
  
  <blockquote>
    <p>The application-specific permission settings do not grant Local Activation permission for the COM Server application with CLSID 
    {6B3B8D23-FA8D-40B9-8DBD-B950333E2C52}
     and APPID 
    {4839DDB7-58C2-48F5-8283-E1D1807D0D7D}
     to the user NT AUTHORITY\LOCAL SERVICE SID (S-1-5-19) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable). This security permission can be modified using the Component Services administrative tool.</p>
    
    <p>The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID 
    {C2F03A33-21F5-47FA-B4BB-156362A2F239}
     and APPID 
    {316CDED5-E4AE-4B15-9113-7055D84DCC97}
     to the user NT AUTHORITY\LOCAL SERVICE SID (S-1-5-19) from address LocalHost (Using LRPC) running in the application container Unavailable SID (Unavailable). This security permission can be modified using the Component Services administrative tool.</p>
  </blockquote>
  
  <p>This is the issue described and solved here: <a href="https://sajiviswam.wordpress.com/2011/04/15/the-machine-default-permission-settings-do-not-grant-local-activation-permission-for-the-com-server-application-with-clsid-000c101c-0000-0000-c000-000000000046-sharepoint-2010/" rel="nofollow noreferrer">https://sajiviswam.wordpress.com/2011/04/15/the-machine-default-permission-settings-do-not-grant-local-activation-permission-for-the-com-server-application-with-clsid-000c101c-0000-0000-c000-000000000046-sharepoint-2010/</a> In my case the affected services are ShellServiceHost and Immersive Shell (contrary to what the blogpost says, I had to look up the CLSID entries in the registry under HKCR\CLSID. I restarted my computer after setting the permissions for the Registry entries, but the security settings of the two components are still grayed out.</p>
  
  <p>Apart from what's in the blogpost under “Change Component Service Owner and Permission” I tried multiple ways to resolve this, without success: setting this up for the Administrator_s_ group, then also giving full control (after a restart) for the Administrator (singular) user; enabling permission inheritance; changing the owner to my (administrator-level) user. I also tried to replace owner with Administrator_s_, and opt to replace all child object permission entries as well.</p>
  
  <p>Still the security settings of the two components are grayed out.</p>
  
  <p><strong>Update 2:</strong></p>
  
  <p>Building on what I've elaborated to be tried under the question this is what helped:</p>
  
  <p>I needed to also set the permissions for the AppIDs in Regedit (see that not just CLSIDs but also APPIDs are present in the error messages) to have full control over them for the Administrators group. After this the Security tab's options weren't grayed out any more for the affected components in Component Services.</p>
  
  <p>Thus I could set Local Activation permission under both components for the Local Service user.</p>
  
  <p>While this gets rid of the errors in the Event Log the Emulator start is still stuck at the same step, however this time without any hint on what may be wrong.</p>
  
  <p><strong>Update 3:</strong></p>
  
  <p>Re-installing pre-3.0 Azure SDK version didn't help. On my laptop the Cloud Service can start and my hunch is that this is because that machine only has v2.9 of the SDK installed.</p>
  
  <p>Related question: <a href="https://stackoverflow.com/questions/7416533/azure-worker-role-getting-stuck-in-role-state-unknown">Azure worker role getting stuck in Role state Unknown</a> (no solution there helped).</p>