2012-11-14 22 views
1

我每次運行應用程序時都面臨着啓動MS Azure模擬器的問題。可能是我所遵循的過程是不正確的。它是這樣的: 1)編輯代碼 2)通過在Visual Studio中打F5來運行項目(Azure項目是啓動項目) 3)VS啓動Ms Azure模擬器 4)最後應用程序在本地主機中運行(在VS內置web服務器)有一些像127.0.0.1:82通過IIS的MS Azure模擬器

一些網址的開銷是,我每次進行更改時,我正在做上述4個步驟。這會消耗大量的開發時間。

我的問題:有沒有辦法直接使用IIS一樣 1)編輯代碼 2運行)建立,並開始在瀏覽器 3的應用程序)安裝到調試的過程W3WP。

我是一個嶄露頭角的項目。您的幫助將不勝感激。

我ServiceDefinition.csdef中:

<?xml version="1.0" encoding="utf-8"?> 
<ServiceDefinition name="ABC" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> 
    <WebRole name="ABCWebRole"> 
    <Sites> 
     <!--<Site name="External" physicalDirectory="..\External"> 
     <Bindings> 
      <Binding name="Http" endpointName="HttpIn" /> 
     </Bindings> 
     </Site>--> 
     <Site name="ABCWebRole" physicalDirectory="..\ABCWebRole"> 
     <Bindings> 
      <Binding name="Http" endpointName="HttpIn" /> 
      <!--<Binding name="HttpsIn" endpointName="HttpsIn" hostHeader="app.ABC.com" />--> 
     </Bindings> 
     </Site> 
    </Sites> 
    <ConfigurationSettings> 
     <Setting name="StorageConnectionString" /> 
     <Setting name="SmtpServer" /> 
     <Setting name="SmtpPort" /> 
     <Setting name="SmtpUsername" /> 
     <Setting name="SmtpPassword" /> 
     <Setting name="myDSUserName" /> 
     <Setting name="myDSPassword" /> 
     <Setting name="myDSIntegratorKey" /> 
     <Setting name="APIUrl" /> 
     <Setting name="AccountManagementUrl" /> 
     <Setting name="myDSEmail" /> 
     <Setting name="myDSAccountId" /> 
     <Setting name="DSmemberPassword" /> 
     <Setting name="QueueNamespace" /> 
     <Setting name="QueueIssuer" /> 
     <Setting name="QueueIssuerKey" /> 
     <Setting name="ShowingFeedbackQueueName" /> 
     <Setting name="ServiceReportQueueName" /> 
    </ConfigurationSettings> 
    <LocalResources> 
     <LocalStorage name="ABCLocal" cleanOnRoleRecycle="true" sizeInMB="1024" /> 
     <LocalStorage name="DiagnosticStore" cleanOnRoleRecycle="true" sizeInMB="7000" /> 
     <LocalStorage name="CustomLogging" cleanOnRoleRecycle="true" sizeInMB="1024" /> 
    </LocalResources> 
    <Certificates> 
     <Certificate name="app.ABC.com" storeLocation="LocalMachine" storeName="My" /> 
    </Certificates> 
    <Endpoints> 
     <InputEndpoint name="HttpsIn" protocol="https" port="443" certificate="app.ABC.com" /> 
     <InputEndpoint name="HttpIn" protocol="http" port="80" /> 
    </Endpoints> 
    <Imports> 
     <Import moduleName="Diagnostics" /> 
    </Imports> 
    </WebRole> 
    <WorkerRole name="ABCWorkerRole" vmsize="ExtraSmall"> 
    <!--Remove diagnostics permissions fix... Remember to remove the associated files<Startup> 
     <Task commandLine="FixDiag.cmd" executionContext="elevated" taskType="background" /> 
    </Startup> 
    --> 
    <Imports> 
     <Import moduleName="Diagnostics" /> 
    </Imports> 
    <ConfigurationSettings> 
     <Setting name="StorageConnectionString" /> 
     <Setting name="SmtpServer" /> 
     <Setting name="SmtpPort" /> 
     <Setting name="SmtpUsername" /> 
     <Setting name="SmtpPassword" /> 
     <Setting name="QueueNamespace" /> 
     <Setting name="QueueIssuer" /> 
     <Setting name="QueueIssuerKey" /> 
     <Setting name="ShowingFeedbackQueueName" /> 
     <Setting name="ServiceReportQueueName" /> 
    </ConfigurationSettings> 
    <LocalResources> 
     <LocalStorage name="DiagnosticStore" cleanOnRoleRecycle="true" sizeInMB="7000" /> 
     <LocalStorage name="CustomLogging" cleanOnRoleRecycle="true" sizeInMB="1024" /> 
    </LocalResources> 
    </WorkerRole> 
</ServiceDefinition> 

回答

2

我通常配置我的服務能夠在Azure中或在IIS中運行。在開始時需要一點時間來設置它,然後再選擇從Visual Studio運行哪個項目,因此當您將.ccproj設置爲啓動項目時,它會在您按F5時運行在Azure中。否則,當您將.csproj設置爲啓動項目時,您可以根據配置Web應用程序的方式,在cassini,IIS Express或本地IIS中運行它。您需要做的一次更改是將掛接到Azure診斷偵聽器的邏輯從web.config移動到Global.asax-> Application_Start()或WebRole.cs-> Onstart()方法,您可以在其中檢查服務是內部或天青環境之外通過RoleEnvironment對象中運行,代碼會喜歡這個

if (RoleEnvironment.IsAvailable) 
{ 
     Trace.Listeners.Add(new DiagnosticMonitorTraceListener 
          { 
          Name = "AzureDiagnostics", 
          Filter = new EventTypeFilter(SourceLevels.All) 
          }); 
} 
else 
{ 
...hook it to a listener that writes logs to an xml file or something 
} 

請記住,蔚藍的環境外運行時,你會失去Azure的具體功能,如閱讀能力.cscfg值通過RoleEnvironment對象(但web.config仍然可以從兩者中訪問)。而且,您還必須通過不同類型的配置手動運行輔助角色(不太直截了當)