Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.27k stars 1.95k forks source link

[FEATURE REQ] Add @ServiceConnection support for CosmosDB, EventHub and Azurite #40329

Open eddumelendez opened 2 months ago

eddumelendez commented 2 months ago

Is your feature request related to a problem? Please describe. Spring Boot 3.1.0 introduced ConnectionDetails. You can read more about it this blog post. There's integration for both Testcontainers and Docker Compose where Spring Boot is able to source the details of the connection.

I can contribute with this feature.

Describe the solution you'd like Add support for ConnectionDetails, then @ServiceConnection would work for CosmosDB, EventHub and Azurite emulators.

@Container
@ServiceConnection
private static final GenericContainer<?> azurite = new GenericContainer<>(
            "mcr.microsoft.com/azure-storage/azurite:latest")
        .withExposedPorts(10000);

Describe alternatives you've considered Keep using DynamicPropertySource to register the connection details manually.

@DynamicPropertySource
static void properties(DynamicPropertyRegistry registry) {
    var azuriteHost = azurite.getHost();
    var azuriteBlobMappedPort = azurite.getMappedPort(AZURE_STORAGE_BLOB_PORT);
    var connectionString = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://%s:%d/devstoreaccount1;"
        .formatted(azuriteHost, azuriteBlobMappedPort);
    registry.add("spring.cloud.azure.storage.blob.connection-string", () -> connectionString);
}

Additional context Add any other context or screenshots about the feature request here.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

github-actions[bot] commented 2 months ago

@chenrujun @moarychan @netyyyy @saragluna

github-actions[bot] commented 2 months ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

saragluna commented 2 months ago

@eddumelendez, thanks for bringing this up, it would be great if you could contribute with this feature.

eddumelendez commented 2 months ago

@saragluna thanks for the quick response. I've submitted #40388 supporting Cosmos, Storage Blob and Storage Queue. Looks like eventhubs emulator is not supported by the SDK yet but will keep an eye and update it once it is supported.

saragluna commented 2 months ago

@eddumelendez, looks great, thanks!