We recommend using Azure Native.
Azure v6.21.0 published on Friday, Mar 7, 2025 by Pulumi
azure.storage.getContainers
Explore with Pulumi AI
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);
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)
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
	})
}
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),
    };
});
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()));
    }
}
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}
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>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]func GetContainers(ctx *Context, args *GetContainersArgs, opts ...InvokeOption) (*GetContainersResult, error)
func GetContainersOutput(ctx *Context, args *GetContainersOutputArgs, opts ...InvokeOption) GetContainersResultOutput> 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)
}public static CompletableFuture<GetContainersResult> getContainers(GetContainersArgs args, InvokeOptions options)
public static Output<GetContainersResult> getContainers(GetContainersArgs args, InvokeOptions options)
fn::invoke:
  function: azure:storage/getContainers:getContainers
  arguments:
    # arguments dictionaryThe following arguments are supported:
- StorageAccount stringId 
- The ID of the Storage Account that the Storage Containers reside in.
- NamePrefix string
- A prefix match used for the Storage Container namefield.
- StorageAccount stringId 
- The ID of the Storage Account that the Storage Containers reside in.
- NamePrefix string
- A prefix match used for the Storage Container namefield.
- storageAccount StringId 
- The ID of the Storage Account that the Storage Containers reside in.
- namePrefix String
- A prefix match used for the Storage Container namefield.
- storageAccount stringId 
- The ID of the Storage Account that the Storage Containers reside in.
- namePrefix string
- A prefix match used for the Storage Container namefield.
- storage_account_ strid 
- The ID of the Storage Account that the Storage Containers reside in.
- name_prefix str
- A prefix match used for the Storage Container namefield.
- storageAccount StringId 
- The ID of the Storage Account that the Storage Containers reside in.
- namePrefix String
- A prefix match used for the Storage Container namefield.
getContainers Result
The following output properties are available:
- Containers
List<GetContainers Container> 
- A containersblock as defined below.
- Id string
- The provider-assigned unique ID for this managed resource.
- StorageAccount stringId 
- NamePrefix string
- Containers
[]GetContainers Container 
- A containersblock as defined below.
- Id string
- The provider-assigned unique ID for this managed resource.
- StorageAccount stringId 
- NamePrefix string
- containers
List<GetContainers Container> 
- A containersblock as defined below.
- id String
- The provider-assigned unique ID for this managed resource.
- storageAccount StringId 
- namePrefix String
- containers
GetContainers Container[] 
- A containersblock as defined below.
- id string
- The provider-assigned unique ID for this managed resource.
- storageAccount stringId 
- namePrefix string
- containers
Sequence[GetContainers Container] 
- A containersblock as defined below.
- id str
- The provider-assigned unique ID for this managed resource.
- storage_account_ strid 
- name_prefix str
- containers List<Property Map>
- A containersblock as defined below.
- id String
- The provider-assigned unique ID for this managed resource.
- storageAccount StringId 
- namePrefix String
Supporting Types
GetContainersContainer  
- DataPlane stringId 
- The data plane ID of the Storage Container.
- Name string
- The name of this Storage Container.
- ResourceManager stringId 
- The resource manager ID of the Storage Container.
- DataPlane stringId 
- The data plane ID of the Storage Container.
- Name string
- The name of this Storage Container.
- ResourceManager stringId 
- The resource manager ID of the Storage Container.
- dataPlane StringId 
- The data plane ID of the Storage Container.
- name String
- The name of this Storage Container.
- resourceManager StringId 
- The resource manager ID of the Storage Container.
- dataPlane stringId 
- The data plane ID of the Storage Container.
- name string
- The name of this Storage Container.
- resourceManager stringId 
- The resource manager ID of the Storage Container.
- data_plane_ strid 
- The data plane ID of the Storage Container.
- name str
- The name of this Storage Container.
- resource_manager_ strid 
- The resource manager ID of the Storage Container.
- dataPlane StringId 
- The data plane ID of the Storage Container.
- name String
- The name of this Storage Container.
- resourceManager StringId 
- 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 azurermTerraform Provider.