好的,所以這是一個修訂後,因爲我可以看到一些反對票,對我來說,解決方案,仍然無法正常工作。作爲背景,從Visual Studio部署到Azure中的Cloud Service會將防惡意軟件重置爲原始狀態(禁用)。所以我試圖默認啓用它。採取設置防惡意軟件默認啓用在Azure雲服務
到此爲止:
- 主Web項目創建啓動文件夾
- 添加到該文件夾STARTUP.CMD文件有以下:
Powershell -ExecutionPolicy Unrestricted .\Startup\startup.ps1 >> "c:\logs\startup_ps_log.txt"
- 將powershell腳本添加到相同的文件夾startup.ps1:
- 修改的雲服務項目ServiceDefinition.csdef中的文件來調用啓動任務:
Set-AzureServiceAntimalwareExtension -ServiceName "myservicename" -AntimalwareConfiguration -Slot "Production"
<Startup priority="-2"> <Task commandLine="startup\startup.cmd" executionContext="elevated" taskType="background" /> </Startup>
我部署我的解決方案,並得到同樣的結果。反惡意軟件仍然被禁用。如果我火了RDP會話到VM和查詢日誌,我可以看到它正在運行,但無法找到特定的PowerShell命令/腳本AzureServiceAntimalwareExtension:
Set-AzureServiceAntimalwareExtension : The term 'Set-AzureServiceAntimalwareExtension' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
有什麼建議?
感謝Pradeep,它仍然留下了很多問題,如何在雲服務啓動時執行PS,XML文件中究竟應該包含哪些內容。但我想這就像大多數MS文檔一樣,技術上準確,但不一定是最有用的。 – Jezbers