[BUG] Microsoft.Azure.Management.ContainerInstance.Models.InstanceView.CurrentState.State is always empty
See original GitHub issueLibrary name and version
Assembly Microsoft.Azure.Management.ContainerInstance, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Describe the bug
I am trying to get the state of a Azure Container Group’s container, here is my code:
` IAzure azure = Microsoft.Azure.Management.Fluent.Azure.Authenticate(azureCredential).WithSubscription(_containerOptions.AzureSubscriptionId); var response = (await client.ContainerGroups.ListByResourceGroupWithHttpMessagesAsync(_containerOptions.ResourceGroup));
foreach (var containerGroup in response.Body.Where(cg=>cg.ProvisioningState == "Succeeded" &&
cg.Name.StartsWith(_containerOptions.AzureContainerPrefix, StringComparison.InvariantCultureIgnoreCase)))
{
If (containerGroup.Containers[0].InstanceView.CurrentState.State == "something")
{
do something
}
`
Expected behavior
Microsoft.Azure.Management.ContainerInstance.Models.InstanceView.CurrentState.State should return actual state of a container, such as Running, Failed, Terminated, etc
Actual behavior
It returns empty string
Reproduction Steps
deploy a container instance, using helloworld image. use the code above to get the state of that container
Environment
I run that code in Azure function
Issue Analytics
- State:
- Created a year ago
- Comments:12 (1 by maintainers)
Top GitHub Comments
I think I found the solution to this in another issue (https://github.com/Azure/azure-sdk-for-net/issues/35764#issuecomment-1557153832).
@gb-8, can you try this? I am just typing here in github so haven’t tested it is 100% syntactically correct, but you get the idea:
The key here is to call
.GetAsync()
on the containerGroup to load the full data.I hope it works for you!
Hi @lidong-zhao, 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.