我正在玩this Azure web role sample。它包含一个派生自RoleEntryPoint
的类和一个包含按钮单击处理程序的.aspx页面。
我在Azure模拟器中测试它。我把以下代码(采用from here)
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
角色OnStart()
和按钮点击处理程序中的。当调用角色OnStart()
时,它恰好在WaIISHost.exe
帐户下的MachineName\\MyLogin
中运行,当调用按钮处理程序代码时,它恰好在w3wp.exe
帐户下MachineName\\NETWORK SERVICE
运行。这令人惊讶。
为什么来自同一角色项目的这些代码段在不同的进程内和不同的帐户下运行?我可以改变吗?
答案 0 :(得分:3)
使用Windows Azure v1.3及更高版本,Web角色利用完整的IIS而不是托管Web Core。 IIS在单独的appdomain中运行。
有关详细信息,请参阅Windows Azure团队中的this blog post。
答案 1 :(得分:3)
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="aExpense.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="aExpense" vmsize="Medium">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="HttpsIn" endpointName="HttpsIn" />
</Bindings>
</Site>
</Sites>
<ConfigurationSettings>
<Setting name="DiagnosticsConnectionString" />
<Setting name="DataConnectionString" />
<Setting name="allowInsecureRemoteEndpoints" />
</ConfigurationSettings>