【问题标题】:Using Azure Cmdlets from a worker role从辅助角色使用 Azure Cmdlet
【发布时间】:2014-12-24 21:11:13
【问题描述】:

是否可以从云中的辅助角色运行 azure powershell 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 控制台运行的,它在那里运行良好。

感谢任何帮助。

谢谢

史蒂夫

【问题讨论】:

  • 这只是一台电脑,所以我看不出有什么理由不这样做。不过,您可能需要先将 Azure Powershell SDK 下载到其中。
  • 辅助角色在未安装 Azure Powershell 的裸机上启动。您可能需要在辅助角色配置中有启动任务才能安装 Azure Powershell 模块。

标签: c# .net powershell azure azure-powershell


【解决方案1】:

我通过使用 C# .NET 库实现了这一点,

Nuget 链接:https://www.nuget.org/packages?q=Microsoft.WindowsAzure.Management

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-11
    • 1970-01-01
    • 2013-08-07
    • 1970-01-01
    • 1970-01-01
    • 2011-08-22
    • 2014-11-09
    • 1970-01-01
    相关资源
    最近更新 更多