1. Packages
  2. Azure Classic
  3. API Docs
  4. storage
  5. getContainers

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

azure.storage.getContainers

Explore with Pulumi AI

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi

Use this data source to access information about the existing Storage Containers within a Storage Account.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";

const example = azure.storage.getContainers({
    storageAccountId: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/sa1",
});
export const containerId = example.then(example => example.containers?.[0]?.resourceManagerId);
Copy
import pulumi
import pulumi_azure as azure

example = azure.storage.get_containers(storage_account_id="/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/sa1")
pulumi.export("containerId", example.containers[0].resource_manager_id)
Copy
package main

import (
	"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/storage"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := storage.GetContainers(ctx, &storage.GetContainersArgs{
			StorageAccountId: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/sa1",
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("containerId", example.Containers[0].ResourceManagerId)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;

return await Deployment.RunAsync(() => 
{
    var example = Azure.Storage.GetContainers.Invoke(new()
    {
        StorageAccountId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/sa1",
    });

    return new Dictionary<string, object?>
    {
        ["containerId"] = example.Apply(getContainersResult => getContainersResult.Containers[0]?.ResourceManagerId),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.storage.StorageFunctions;
import com.pulumi.azure.storage.inputs.GetContainersArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var example = StorageFunctions.getContainers(GetContainersArgs.builder()
            .storageAccountId("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/sa1")
            .build());

        ctx.export("containerId", example.applyValue(getContainersResult -> getContainersResult.containers()[0].resourceManagerId()));
    }
}
Copy
variables:
  example:
    fn::invoke:
      function: azure:storage:getContainers
      arguments:
        storageAccountId: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/sa1
outputs:
  containerId: ${example.containers[0].resourceManagerId}
Copy

Using getContainers

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getContainers(args: GetContainersArgs, opts?: InvokeOptions): Promise<GetContainersResult>
function getContainersOutput(args: GetContainersOutputArgs, opts?: InvokeOptions): Output<GetContainersResult>
Copy
def get_containers(name_prefix: Optional[str] = None,
                   storage_account_id: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetContainersResult
def get_containers_output(name_prefix: Optional[pulumi.Input[str]] = None,
                   storage_account_id: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetContainersResult]
Copy
func GetContainers(ctx *Context, args *GetContainersArgs, opts ...InvokeOption) (*GetContainersResult, error)
func GetContainersOutput(ctx *Context, args *GetContainersOutputArgs, opts ...InvokeOption) GetContainersResultOutput
Copy

> Note: This function is named GetContainers in the Go SDK.

public static class GetContainers 
{
    public static Task<GetContainersResult> InvokeAsync(GetContainersArgs args, InvokeOptions? opts = null)
    public static Output<GetContainersResult> Invoke(GetContainersInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetContainersResult> getContainers(GetContainersArgs args, InvokeOptions options)
public static Output<GetContainersResult> getContainers(GetContainersArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: azure:storage/getContainers:getContainers
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

StorageAccountId This property is required. string
The ID of the Storage Account that the Storage Containers reside in.
NamePrefix string
A prefix match used for the Storage Container name field.
StorageAccountId This property is required. string
The ID of the Storage Account that the Storage Containers reside in.
NamePrefix string
A prefix match used for the Storage Container name field.
storageAccountId This property is required. String
The ID of the Storage Account that the Storage Containers reside in.
namePrefix String
A prefix match used for the Storage Container name field.
storageAccountId This property is required. string
The ID of the Storage Account that the Storage Containers reside in.
namePrefix string
A prefix match used for the Storage Container name field.
storage_account_id This property is required. str
The ID of the Storage Account that the Storage Containers reside in.
name_prefix str
A prefix match used for the Storage Container name field.
storageAccountId This property is required. String
The ID of the Storage Account that the Storage Containers reside in.
namePrefix String
A prefix match used for the Storage Container name field.

getContainers Result

The following output properties are available:

Containers List<GetContainersContainer>
A containers block as defined below.
Id string
The provider-assigned unique ID for this managed resource.
StorageAccountId string
NamePrefix string
Containers []GetContainersContainer
A containers block as defined below.
Id string
The provider-assigned unique ID for this managed resource.
StorageAccountId string
NamePrefix string
containers List<GetContainersContainer>
A containers block as defined below.
id String
The provider-assigned unique ID for this managed resource.
storageAccountId String
namePrefix String
containers GetContainersContainer[]
A containers block as defined below.
id string
The provider-assigned unique ID for this managed resource.
storageAccountId string
namePrefix string
containers Sequence[GetContainersContainer]
A containers block as defined below.
id str
The provider-assigned unique ID for this managed resource.
storage_account_id str
name_prefix str
containers List<Property Map>
A containers block as defined below.
id String
The provider-assigned unique ID for this managed resource.
storageAccountId String
namePrefix String

Supporting Types

GetContainersContainer

DataPlaneId This property is required. string
The data plane ID of the Storage Container.
Name This property is required. string
The name of this Storage Container.
ResourceManagerId This property is required. string
The resource manager ID of the Storage Container.
DataPlaneId This property is required. string
The data plane ID of the Storage Container.
Name This property is required. string
The name of this Storage Container.
ResourceManagerId This property is required. string
The resource manager ID of the Storage Container.
dataPlaneId This property is required. String
The data plane ID of the Storage Container.
name This property is required. String
The name of this Storage Container.
resourceManagerId This property is required. String
The resource manager ID of the Storage Container.
dataPlaneId This property is required. string
The data plane ID of the Storage Container.
name This property is required. string
The name of this Storage Container.
resourceManagerId This property is required. string
The resource manager ID of the Storage Container.
data_plane_id This property is required. str
The data plane ID of the Storage Container.
name This property is required. str
The name of this Storage Container.
resource_manager_id This property is required. str
The resource manager ID of the Storage Container.
dataPlaneId This property is required. String
The data plane ID of the Storage Container.
name This property is required. String
The name of this Storage Container.
resourceManagerId This property is required. String
The resource manager ID of the Storage Container.

Package Details

Repository
Azure Classic pulumi/pulumi-azure
License
Apache-2.0
Notes
This Pulumi package is based on the azurerm Terraform Provider.

We recommend using Azure Native.

Azure v6.22.0 published on Tuesday, Apr 1, 2025 by Pulumi