I have the following code to stop an Azure container instance and would like to start it using similar.
using Microsoft.Azure.Management.Compute.Fluent.Models;
using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal("XXXX", "XXXX", "XXXX", AzureEnvironment.AzureGlobalCloud);
var azure = Azure
.Configure()
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
.Authenticate(credentials)
.WithSubscription("XXXXX");
var containerName = "mycontainer";
var containerGroup = azure.ContainerGroups.GetByResourceGroup("myResourceGroup", containerName);
if (containerGroup.State == "Running")
{
containerGroup.Stop();
}
I would like to do the same and start my azure container instance. So where is containerGroup.Start(); ? This does not appear to exist in the interface. I have tried using containerGroup.Restart(); but this does not work from a stopped state. I need to be able to do this from within C# code and would like to avoid powershell if possible.