Azure / azure-functions-python-library

Azure Functions Python SDK
MIT License
155 stars 67 forks source link

fix: value resolution for BlobSource.EVENT_GRID #247

Closed hallvictoria closed 1 month ago

hallvictoria commented 1 month ago

When defining a BlobTrigger using BlobSource.EVENT_GRID, the source value was not being resolved correctly, and the error below was being thrown. This is because the host was receiving EVENT_GRID as the source value, instead of the correct value "EventGrid". This changes what source is set to in the BlobTrigger decorator. If source is defined, source is set to the EVENT_GRID value. If source is not defined, source is set to null and is ignored.

@app.blob_trigger(arg_name="myblob",
                  path="mycontainer",
                  data_type=func.DataType.STRING,
                  source = func.BlobSource.EVENT_GRID,
                  connection="AzureWebJobsStorage") 
The 'blob_trigger' function is in error: Unable to configure binding 'myblob' of type 'blobTrigger'. This may indicate invalid function.json properties. Could not convert 'EVENT_GRID' to BlobTriggerSource. Error converting value "EVENT_GRID" to type 'Microsoft.Azure.WebJobs.BlobTriggerSource'. Path 'source', line 1, position 165. Requested value 'EVENT_GRID' was not found.

Fixes: https://github.com/Azure/azure-functions-python-worker/issues/1582