Skip to content

Using Blobclient with managed identity #44

@Oliver-CI

Description

@Oliver-CI

Using Blobclient with managed identity

Currently it is not possible to use managed identity in combination with the use_sdk_type feature.
As in the Hydrator we always check for the AzureWebJobsStorage env to be present. Whilst using managed identity this property is not used as it only accepts formatting for a connectionString.

Example

I have the following function trigger

    @FunctionName("BlobFunction")
    fun handle(
        @BlobTrigger(
            name = "content",
            path = "container/{fileName}.json"
        ) blob: BlobClient,
        @BindingName("fileName") fileName: String,
        context: ExecutionContext
    ) {
       logger.info {  "received $fileName" }
    }

With the following environment variables defined:
AzureWebJobsStorage__accountName = mystorageaccount
JAVA_ENABLE_SDK_TYPES = true

Problem

Yet when starting this function the BlobClientHydrator will complain the AzureWebJobsStorage is not set.
https://github.com/Azure/azure-functions-java-additions/blob/dev/azure-functions-java-sdktypes/src/main/java/com/microsoft/azure/functions/sdktype/blob/BlobClientHydrator.java#L29

If you then also configure the AzureWebJobsStorage with a dummyvalue "foo=bar"
The default net sdk will then fail as the AzureWebJobsStorage is not correctly formatted.

https://github.com/Azure/azure-sdk-for-net/blob/593527287e9274f87cf00fa3192d499226423616/sdk/storage/Azure.Storage.Common/src/Shared/StorageConnectionString.cs#L238

Suggestion

I believe we could resolve this by not specifically checking the envVar but also checking if any of the 3 suffix variants are defined.

  • System.getenv(envVar + "__accountName");
  • System.getenv(envVar + "__serviceUri");
  • System.getenv(envVar + "__blobServiceUri");

final note

If my assumptions mentioned above are incorrect please advise towards a working example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions