Skip to content
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

Closed
ras-relativity opened this issue Nov 24, 2024 · 5 comments
Assignees
Labels
Compute customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@ras-relativity
Copy link

ras-relativity commented Nov 24, 2024

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

@github-actions github-actions bot added Compute customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 24, 2024
Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@ArthurMa1978
Copy link
Member

Thank you @ras-relativity for your feedback, @HarveyLink please look into this issue.

@melina5656 melina5656 assigned melina5656 and unassigned HarveyLink Nov 25, 2024
@welovej welovej assigned welovej and unassigned melina5656 Jan 14, 2025
@welovej
Copy link
Member

welovej commented Jan 15, 2025

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);

@welovej welovej added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Jan 15, 2025
@github-actions github-actions bot removed the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jan 15, 2025
Copy link

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.

Copy link

Hi @ras-relativity, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compute customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

5 participants