Can I detect if my code is executing in an Azure worker role?

前端 未结 5 1886
情深已故
情深已故 2021-01-18 13:24

I have some shared assemblies/projects that are used within Winforms apps, windows services and now Azure worker roles.

Is there any way that I can detect at runtime

5条回答
  •  失恋的感觉
    2021-01-18 14:00

    You can check for the presence of the RoleRoot environment variable (for Cloud Services at least):

    • MSDN

    Or, why not simply add a setting to your config (AppSettings or Service Configuration):

      
        ...
        
      
    

    Then you can simply check if the setting exists with a specific value to see where you're running. This also means that during your (automated) build or deploy process you'll need to include this setting (this is possible with XDT for example).

提交回复
热议问题