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

[SDK Binding - Blob] Binding to BlobContainerClient should not require you to provide a blob path #1337

Closed
liliankasem opened this issue Feb 13, 2023 · 2 comments · Fixed by Azure/azure-sdk-for-net#37124
Assignees
Labels

Comments

@liliankasem
Copy link
Member

liliankasem commented Feb 13, 2023

When binding to BlobContainerClient as an input binding, you still need to provide a blob name in the input binding i.e. BlobInput("input-container/sample1.txt"

[Function(nameof(BlobContainerClientInputFunction))]
public async Task<HttpResponseData> BlobContainerClientInputFunction(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
    [BlobInput("input-container/sample1.txt")] BlobContainerClient client)

But since we are binding to a container, it doesn't make sense to have to provide a blob name in the binding; instead I would expect that you could bind to just the container like this:

[Function(nameof(BlobContainerClientInputFunction))]
public async Task<HttpResponseData> BlobContainerClientInputFunction(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
    [BlobInput("input-container")] BlobContainerClient client)

This does not work today and you get the following error message:

Invalid blob path specified : 'input-container'. Blob identifiers must be in the format 'container/blob'

Note: this is different to a blob trigger which lets you bind to just the container, and it is not the same as IsBatched which also lets you bind to only a container but expects a collection binding i.e. BlobContainerClient[] which does not make sense for this scenario

Proposed Change

  1. On the WebJobs extension side we relax the rules to allow input binding with just the container name
  2. On the worker side we will have more checks in place to make sure customers do not bind a string/byte[] or anything other than a BlobContainerClient to a container path
@fabiocav
Copy link
Member

Assigning to @liliankasem for additional context on the change we'll be proposing to the blob extension.

@liliankasem liliankasem changed the title Binding to BlobContainerClient should not require you to provide a blob path [SDK Binding - Blob] Binding to BlobContainerClient should not require you to provide a blob path Feb 17, 2023
@liliankasem liliankasem removed their assignment Jun 8, 2023
@fabiocav fabiocav added this to the Functions Sprint 148 milestone Jun 8, 2023
@aishwaryabh
Copy link
Contributor

The Blob WebJobs extensions has a property called isContainerBinding for determining if the passed in input can be parsed correctly. We basically need to pass in isContainerBinding = true here, and as of today there is no way to do this other than adding a new attribute.

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