Why am I getting SEHException when calling RoleEnvironment.GetConfigurationSettingValue(“MYKEY”)?

前端 未结 5 1126
旧巷少年郎
旧巷少年郎 2020-11-29 04:04

I\'m trying to call RoleEnvironment.GetConfigurationSetting(\"SOMEKEY\") like so:

public partial class AzureBasePage : System.Web.UI.Page
{
             


        
5条回答
  •  有刺的猬
    2020-11-29 04:37

    Although many point out that you should run with dev/Azure fabric instead of the asp.net development server, I think it's worth mentioning that you need to choose the correct execution model when you publish your application to Azure if you want to use the RoleEnvironment.

    There're 3 models as of now:

    • VM
    • Web Site
    • Cloud Service

    Please refer to here: http://azure.microsoft.com/en-us/documentation/articles/fundamentals-application-models for more details.

    And especially the following paragraph:

    Cloud Services, which was the initial execution model provided by Azure, is an explicitly PaaS approach. While the line between PaaS and web hosting is blurry, Cloud Services differs in some important ways from Web Sites, including the following:

    • Unlike Web Sites, Cloud Services gives you administrative access to your application's VMs. This lets you install arbitrary software that your application needs, something that's not possible with Web Sites.
    • Because Cloud Services offers both web roles and worker roles, it's a better choice than Web Sites for multi-tier applications that need separate VMs for their business logic.
    • Cloud Services provides separate staging and production environments, making application updates somewhat smoother than Web Sites.
    • Unlike Web Sites, you can use networking technologies such as Azure Virtual Network and Azure Connect to hook on-premises computers to Cloud Services applications.
    • Cloud Services lets you use Remote Desktop to connect directly to an application's VMs, something that's not possible with Web Sites.

    You can check the RoleEnvironment.IsAvailable. If it is false, your application is not running with Azure runtime, which means the RoleEnvironment is not applicable.

提交回复
热议问题