Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly List Storage Containers #2873

Merged
merged 3 commits into from
Feb 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions azurerm/resource_arm_storage_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,30 @@ func resourceArmStorageContainerRead(d *schema.ResourceData, meta interface{}) e
return nil
}

containers, err := blobClient.ListContainers(storage.ListContainersParameters{
var container *storage.Container
listParams := storage.ListContainersParameters{
Prefix: id.containerName,
Timeout: 90,
})
if err != nil {
return fmt.Errorf("Failed to retrieve storage containers in account %q: %s", id.containerName, err)
}

var container *storage.Container
for _, cont := range containers.Containers {
if cont.Name == id.containerName {
container = &cont
for {
resp, err := blobClient.ListContainers(listParams)
if err != nil {
return fmt.Errorf("Failed to retrieve storage resp in account %q: %s", id.containerName, err)
}

for _, c := range resp.Containers {
if c.Name == id.containerName {
container = &c
break
}
}

if resp.NextMarker == "" {
break
}

listParams.Marker = resp.NextMarker
}

if container == nil {
Expand Down