-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUERY] How to re-invoke a managed RunCommand that has already been created #47307
Comments
Thank you for your feedback. Tagging and routing to the team member best able to assist. |
Thank you @ras-relativity for your feedback, @HarveyLink please look into this issue. |
hi @ras-relativity what kind of script are you running in RunCommand ? if powershell on windows, the code below works: // Retrieve the created RunCommand
Response<VirtualMachineRunCommandResource> commandResponse = await commandCollection.GetAsync(commandName, expand: "InstanceView");
VirtualMachineRunCommandResource runCommand = commandResponse.Value;
// Create input and re-execute RunCommand, supported only for Windows VMs
var runCommandInput = new RunCommandInput("RunPowerShellScript")
{
Script = { runCommand.Data.Source.Script }
};
Console.WriteLine("Re-executing RunCommand...");
ArmOperation<VirtualMachineRunCommandResult> operation = await virtualMachineResource.RunCommandAsync(WaitUntil.Completed, runCommandInput);
VirtualMachineRunCommandResult result = operation.Value;
// Output the results
Console.WriteLine("RunCommand Output:");
var messages = result.Value.Where(w => w.Code == "ComponentStatus/StdOut/succeeded").Select(s => s.Message).FirstOrDefault();
Console.WriteLine(messages); if bash on linux, the code below works: // Retrieve the created RunCommand
Response<VirtualMachineRunCommandResource> commandResponse = await commandCollection.GetAsync(commandName, expand: "InstanceView");
VirtualMachineRunCommandResource runCommand = commandResponse.Value;
// Create input and re-execute RunCommand, supported only for Windows VMs
var runCommandInput = new RunCommandInput("RunShellScript")
{
Script = { runCommand.Data.Source.Script }
};
Console.WriteLine("Re-executing RunCommand...");
ArmOperation<VirtualMachineRunCommandResult> operation = await virtualMachineResource.RunCommandAsync(WaitUntil.Completed, runCommandInput);
VirtualMachineRunCommandResult result = operation.Value;
// Output the results
Console.WriteLine("RunCommand Output:");
var messages = result.Value.FirstOrDefault().Message;
Console.WriteLine(messages); |
Hi @ras-relativity. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation. |
Hi @ras-relativity, since you haven’t asked that we |
Library name and version
Azure.ResourceManager.Compute 1.6.0
Query/Question
Ive created a named Managed RunCommand with VirtualMachineRunCommandCollection.CreateOrUpdateAsync().
It automatically executed the command on create, and gives output when checked with GetAsync(..., expand: "InstanceView", ...)
I've read the output of the command, now I want to call the command again and have it be re-invoked on the server and output updated.
How can I do this? running CreateOrUpdateAsync again does not re-execute the command
Environment
Linux Ubuntu 20.04 Azure VM
The text was updated successfully, but these errors were encountered: