Does metadata fetch like ECS_CONTAINER_METADATA_URI_V4 in ECS Fargate

NS 40 Reputation points

We have a specific use case where we need to fetch within the running container instance using<subscriber-id>/resourceGroups/<resource group id>/resourceGroups/<resource group name>/providers/Microsoft.ContainerInstance/containerGroups/<container group name> .
It appears that this API needs Subscriber ID/Container Group name/ Resource Group name which may not be available.

Is there a way to fetch this data within the container instance running some metadata API.
Some thing similar to ECS_CONTAINER_METADATA_URI_V4 like ECS Fargate

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
649 questions
{count} votes

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 24,636 Reputation points

    Hello Neha

    Welcome to Microsoft Q&A Platform, thanks for posting your query here.

    Yes, you can use the Azure Instance Metadata Service (IMDS) to retrieve metadata for your container instance. IMDS is a REST API that's available at a well-known, non-routable IP address ( You can only access it from within the VM. Communication between the VM and IMDS never leaves the host.

    To access IMDS, you can use the following sample code:

    curl -H Metadata:true ""

    This will return a JSON object containing metadata about the instance, including the subscription ID, resource group name, and container group name.

    You can then parse the JSON object to extract the information you need. Here's an example of how to extract the subscription ID:

    curl -H Metadata:true "" | jq -r .compute.subscriptionId'

    This will return the subscription ID as a string.

    I hope this information helps you.

    0 comments No comments