2014-10-29 115 views
1

是否可以從雲中的輔助角色運行azure powershell cmdlet?從輔助角色使用Azure Cmdlet

如果有人有辦法做到這一點,並可以提供某種解釋如何獲得它的所有設置?

我到目前爲止,但它不會工作。

using (PowerShell powerShell = PowerShell.Create()) 
{ 

    powerShell.AddCommand("Set-ExecutionPolicy"); 
    powerShell.AddParameter("ExecutionPolicy", "RemoteSigned"); 
    Collection<PSObject> output = powerShell.Invoke(); 
    ProcessPowerShellOutput(output); 

    powerShell.AddCommand("Import-Module"); 
    powerShell.AddParameter("Name", "Azure"); 
    output = powerShell.Invoke(); 
    ProcessPowerShellOutput(output); 

    powerShell.AddCommand("Import-AzurePublishSettingsFile"); 
    powerShell.AddParameter("PublishSettingsFile", @"<PATH>"); 
    output = powerShell.Invoke(); 
    ProcessPowerShellOutput(output); 

    powerShell.AddCommand("Set-AzureSubscription"); 
    powerShell.AddParameter("SubscriptionName", @"SUB NAME"); 
    output = powerShell.Invoke(); 
    ProcessPowerShellOutput(output); 

    powerShell.AddCommand("Set-AzureRole"); 
    powerShell.AddParameter("ServiceName", @"deploymentconfigtest"); 
    powerShell.AddParameter("Slot", @"Production"); 
    powerShell.AddParameter("RoleName", @"DummyWorkerRole"); 
    powerShell.AddParameter("Count", 2); 
    output = powerShell.Invoke(); 

    ProcessPowerShellOutput(output); 

} 

這就是我使用powershell控制檯運行,它在那裏運行良好。

任何幫助表示讚賞。

感謝

史蒂夫

+0

這只是一個電腦,所以我認爲沒有理由不能。您可能需要首先將Azure Powershell SDK下載到它。 – arco444 2014-10-29 10:10:08

+0

在沒有安裝Azure Powershell的情況下使用裸機啓動輔助角色。您可能需要在輔助角色配置中安裝啓動任務才能安裝Azure Powershell模塊。 – slepox 2014-10-31 00:09:59

回答