2013-06-02 66 views
3

我有一個工作部署。 我已經加入到雲服務角色的配置文件:Azure中的不健康實例

<Startup> 
     Task commandLine="EnableCompression.cmd" executionContext="elevated" taskType="simple"></Task> 
    </Startup> 

然後在cmd文件:

%windir%\system32\inetsrv\appcmd set config /section:urlCompression /doDynamicCompression:True /commit:apphost 
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost 

當發佈此天青我得到:

Your role instances have recycled a number of times during an update or upgrade operation. This indicates that the new version of your service or the configuration settings you provided when configuring the service prevent the role instances from running. Verify your code does not throw unhandled exceptions and that your configuration settings are correct and then start another update or upgrade operation. 

Cmd文件具有COPY ALWAYS屬性。所以這應該沒問題。 從配置中刪除<Startup>標記時,它是成功的。

以上好像部署失敗

這可能是什麼原因造成的? 謝謝!

回答

4

確保啓動命令的返回代碼始終爲零,否則azure會認爲它失敗並回收您的角色。

您可以將'exit 0'作爲最後一條命令添加到批處理文件中,以確保它以成功代碼0退出。

最有可能的,命令失敗,或者,它確實成功,但返回代碼爲非零信號沒有發生任何變化等

+0

但它並沒有解決它基本上隱藏問題的原因的問題。最後加入「退出0」是否正確? – loop

+0

@loop有時很適合。例如,在上面的場景中,appcmd的退出代碼可以非零,這意味着「此配置設置已經應用」,因此您可以忽略它。 「退出0」禁止此代碼。 – Andrew

+0

@但它可能發生的配置設置是錯誤的,那麼在這種情況下,我們只是隱藏錯誤。它發生在我身上。 – loop