2017-11-25 122 views
0

好的,所以這是一個修訂後,因爲我可以看到一些反對票,對我來說,解決方案,仍然無法正常工作。作爲背景,從Visual Studio部署到Azure中的Cloud Service會將防惡意軟件重置爲原始狀態(禁用)。所以我試圖默認啓用它。採取設置防惡意軟件默認啓用在Azure雲服務

到此爲止:

  1. 主Web項目創建啓動文件夾
  2. 添加到該文件夾​​STARTUP.CMD文件有以下:
 
    Powershell -ExecutionPolicy Unrestricted .\Startup\startup.ps1 >> "c:\logs\startup_ps_log.txt" 
  • 將powershell腳本添加到相同的文件夾startup.ps1:
  •   
        Set-AzureServiceAntimalwareExtension -ServiceName "myservicename" -AntimalwareConfiguration -Slot "Production" 
    
  • 修改的雲服務項目ServiceDefinition.csdef中的文件來調用啓動任務:
  •  
        <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. 
    

    有什麼建議?

    回答

    0

    注意: Microsoft反惡意軟件在雲服務平臺中處於禁用狀態,並且需要Azure應用程序執行操作才能啓用它。

    使用集-AzureServiceAntimalwareExtension反惡意軟件cmdlet來啓用和配置微軟反惡意軟件爲您的雲服務作爲

    https://docs.microsoft.com/en-us/powershell/module/Azure/Set-AzureServiceAntimalwareExtension?view=azuresmps-4.0.0

    +0

    感謝Pradeep,它仍然留下了很多問題,如何在雲服務啓動時執行PS,XML文件中究竟應該包含哪些內容。但我想這就像大多數MS文檔一樣,技術上準確,但不一定是最有用的。 – Jezbers

    0

    記錄在你的第三步,你寫的:

    Set-AzureServiceAntimalwareExtension -ServiceName "myservicename" -AntimalwareConfiguration -Slot "Production" 
    

    但是你沒有指定xml文件後-AntimalwareConfiguration

    +0

    我的理解是可選的 – Jezbers

    +0

    我認爲它是「可選的」,因爲您可以添加該參數,並且它將查找配置,或者可以將其忽略。 [這裏](https://gallery.technet.microsoft.com/Antimalware-For-Azure-5ce70efe/view/Discussions)是xml文件的一個例子,如果你需要的話。 另外,退一步。您是否安裝了[Azure AD模塊](https://support.microsoft.com/zh-CN/help/2669552/-the-term-cmdlet-name-is-not-recognized-error-when-youtry -to-運行海岸)? – Sencha718

    +0

    謝謝你嘗試了一個基本的XML文件,但結果相同 – Jezbers

    0

    這個問題似乎是,您嘗試從雲服務本身激活AntiMalware。但是應該從運行部署的計算機完成,可以從Visual Studio for VM或通過ARM PowerShell CmdLets for Cloud Services完成。

    看到這個documentation here

    +0

    感謝Roderick,但是這對於我們當前的部署機制並不合適,我的理解是它可以這樣完成,我們似乎錯過了一些東西。 – Jezbers

    +0

    在這種情況下,就像@ gvee所說的,您需要導入模塊。 –

    0

    術語'Set-AzureServiceAntimalwareExtension'不被識別爲cmdlet,函數,腳本文件或可操作程序的名稱。檢查名稱的拼寫,或者如果包含路徑,請驗證路徑是否正確,然後重試。

    PowerShell會話不知道那個函數是什麼,這意味着包含代碼的模塊沒有被導入。

    加入這一行之前,你的函數調用來給它一個機會;-)

    Import-Module Azure* -ErrorAction Stop 
    

    如果由於某種原因失敗,那麼很可能在模塊上沒有你的目標,所以you'll need to install it!

    +0

    謝謝Gvee,嘗試了第一個這樣的結果。安裝讓我感到困惑,因爲MS docs所有狀態默認情況下都處於禁用狀態。不過我會探索。 – Jezbers