Creating virtual machine through c# SDK kills process

Rob Schenkel 0 Reputation points
2024-08-19T19:29:04.4033333+00:00

I'm working on a console application using the Azure C# SDK (Azure.ResourceManager.Compute version 1.5.0.0) to create a virtual machine.

I have the following objects, both of which are not null:

private readonly ResourceGroupResource _resourceGroup;

var vmCollection = _resourceGroup.GetVirtualMachines();

The problem occurs when I execute the following command:

var response = await vmCollection.CreateOrUpdateAsync(WaitUntil.Completed, name, vmData);

The VM is created successfully, but the console application immediately exits afterward, even though there are additional lines of code to execute. Using Fiddler to monitor the network traffic shows that the result of the call is HTTP/1.1 201.

Has anyone encountered this issue or know how to prevent the console app from terminating after the VM creation?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,035 questions
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rob Schenkel 0 Reputation points
    2024-08-19T19:48:16.8933333+00:00

    Stupid mistake... the code to call my method was missing an await.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.