【问题标题】:Azure custom script stuck in Transitioning stateAzure 自定义脚本卡在过渡状态
【发布时间】:2017-08-11 12:42:20
【问题描述】:

我的 azure 帐户上有一个虚拟机,我想传递一个简单的 powershell 脚本,它应该只打开 Microsoft Paint 程序。

powershell脚本是:

& "C:\Windows\system32\mspaint.exe"  

这是获取 vm 并尝试在远程 vm 上应用此脚本的代码。

var testingVm = _azure.VirtualMachines.GetById(
            "...");
        testingVm.Update()
            .DefineNewExtension("InstallSoftware")
            .WithPublisher("Microsoft.Compute")
            .WithType("CustomScriptExtension")
            .WithVersion("1.9")
            .WithPublicSetting("fileUris", new string[]
            {
                "https://.../powershellscripts/OpenPaint.ps1"
            })
            .WithProtectedSetting("Url", "https://.../powershellscripts/gource-0.42-setup.exe")
            .WithProtectedSetting("commandToExecute", "powershell -ExecutionPolicy Bypass -File OpenPaint.ps1")
            .Attach()
            .Apply();

文件被下载,脚本正确放置在 C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension\1.9\Downloads\0 文件夹中,bu Paint 未打开,并且在 Azure 门户上的状态为扩展名永远设置为“过渡”。 (我还确保 vm 在那个目录中有画,并且执行策略设置为 Bypass)。

我做错了什么?

【问题讨论】:

    标签: c# .net powershell azure azure-web-app-service


    【解决方案1】:

    我很确定没有任何问题。它在系统上下文下启动绘画(因此您无法在屏幕上看到它)并且它永远卡在那里。所以我猜它和你设计的完全一样(但设计有缺陷)。

    尝试在脚本中做一些有意义的事情(而不是你正在做的事情):

    get-process > c:\1.txt
    

    【讨论】:

    • 作为额外的东西,我如何能够从这个 C# 代码将参数传递给那个 powershell 脚本?
    • 很遗憾无法为您提供帮助。从未使用过 c# sdk
    猜你喜欢
    • 2021-11-05
    • 2020-01-08
    • 1970-01-01
    • 2011-11-03
    • 2010-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多