Container Instane Exec API

Sameer 0 Reputation points
2024-03-12T21:14:28.9433333+00:00

The API https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.ContainerInstance/containerGroups/$groupName/containers/$containerName/exec?api-version=2023-05-01 returns a web socket URL with password.

Is there any documentation about how to invoke it with a client such as curl or websocat ?

https://video2.skills-academy.com/en-us/rest/api/container-instances/containers/execute-command?view=rest-container-instances-2023-05-01&tabs=HTTP

Azure CLI az container exec automatically opens web socket but does not provide any details when used with --debug option.

Would Java API class ContainerExec also automatically interact with WebSocket and provide stdout of the command? https://video2.skills-academy.com/en-us/java/api/com.microsoft.azure.management.containerinstance.containerexec?view=azure-java-legacy

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
669 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anveshreddy Nimmala 3,460 Reputation points Microsoft Vendor
    2024-03-13T06:47:44.9366667+00:00

    Hello Sameer,

    Welcome to microsoft Q&A, Thankyou for posting your query here.

    There is no specific documentation available for invoking the web socket URL returned by the API using a client such as curl or websocat.

    you can use the Azure CLI az container exec command to automatically open the web socket and interact with it.

    az container exec -g MyResourceGroup --name mynginx --container-name nginx --exec-command "/bin/bash"

    The --debug option in the az container exec command doesn't provide details about the WebSocket URL because it's primarily meant for debugging the Azure CLI itself, not the WebSocket connection or command execution within the container.

    When you use --debug, it generates verbose output, including HTTP requests and responses exchanged between the Azure CLI and Azure services.

    The ContainerExec class in the Azure Java SDK doesn't inherently interact with WebSocket or provide stdout of the command automatically.Hope this helps you.If an answer has been helpful, please consider accepting the answer to help increase visibility of this question for other members of the Microsoft Q&A community. If not, please let us know what is still needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!

    fea50015-1469-47b5-a1a6-056c9118f9bf