Skip to content

[WIP] Refactor BlobClient into a StorageBlobService for per-call subscription#7074

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/refactor-blobclient-to-storageblobservice
Draft

[WIP] Refactor BlobClient into a StorageBlobService for per-call subscription#7074
Copilot wants to merge 1 commit intomainfrom
copilot/refactor-blobclient-to-storageblobservice

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

Thanks for assigning this issue to me. I'm starting to work on it and will keep this PR's description up to date as I form a plan and make progress.

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor BlobClient into a StorageBlobService following per-call subscription pattern</issue_title>
<issue_description>## Summary

The current BlobClient in cli/azd/pkg/azsdk/storage/ is architecturally unique compared to other Azure service clients in the codebase. It binds the subscription/tenant at construction time via AccountConfig, whereas all other services (KeyVault, ContainerApps, ContainerRegistry, AppService, etc.) accept subscriptionId per-call and store only a SubscriptionCredentialProvider.

Current pattern (BlobClient — exception)

// Constructor locks in subscription via AccountConfig
func NewBlobSdkClient(credentialProvider, accountConfig *AccountConfig, ...) (*azblob.Client, error)

// Methods have no subscription parameter
type BlobClient interface {
    Download(ctx context.Context, blobPath string) (io.ReadCloser, error)
    Upload(ctx context.Context, blobPath string, reader io.Reader) error
    // ...
}

Standard pattern (KeyVault, ContainerApps, etc.)

// Constructor takes credential provider only
func NewKeyVaultService(credentialProvider, ...) KeyVaultService

// Methods accept subscriptionId per-call
GetKeyVault(ctx, subscriptionId, resourceGroup, vaultName) (*KeyVault, error)

Interestingly, FileShareService in the same storage package already follows the standard per-call pattern.

Proposal

Refactor the blob storage abstraction into a StorageBlobService that:

  1. Follows the per-call subscriptionId pattern used by other Azure services
  2. Stores a SubscriptionCredentialProvider rather than pre-resolved credentials
  3. Can be consumed by the remote state feature (and any future blob storage consumers) without being locked to a single subscription at construction time

This is a code & design improvement — the current implementation works correctly for its single use case (remote state), but consolidating the pattern improves consistency and future extensibility.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor BlobClient into a StorageBlobService following per-call subscription pattern

2 participants