Search code examples
azureazure-storageazure-functionsazure-blob-storage

Azure Function BlobContainer.ListBlob available in Portal CScript, not in VS C#


First I was developpign some test function with the portal, there the function on a BlobContainer ListBlob was available. Now i've switched to VS2017 to get some more complicated code, but there the ListBlob is not available, it should be ListBlobsSegmentedAsync. But that is a totally dirrerent approach ... I just would like to understand why its possible in the Portal and not in VS ...


Solution

  • It's caused by the difference of Storage SDK used in different Function runtime.

    On Azure portal, check Runtime version in Function app settings, you probably see 1.0.11959.0 (~1). It means code created on portal right now targets at .NET Framework 4.7. For Storage SDK based on .NET Framework, both ListBlobs and ListBlobsSegmentedAsync are valid on CloudBlobContainer. enter image description here

    Turn to local dev in VS, you may have chosen v2 when creating Azure Function. v2 Functions targets at .NET Standard 2.0 and runs on ~2 Function runtime(.NET Core 2). Storage SDK based on .NET Core only provides ListBlobsSegmentedAsync for list operation on container.

    enter image description here

    To keep consistent, you can create v1 function in VS or change function runtime on Function app settings. Note that if you choose the later, you need to delete old functions first as they will become invalid in different runtime.