testcontainers-dotnet
testcontainers-dotnet copied to clipboard
feat: add azure app configuration module
What does this PR do?
This change adds an Azure App Configuration module using Emulator for Azure App Configuration.
Why is it important?
This module allows developers to more easily integration test applications that are dependent on Azure App Configuration.
Related issues
- Closes #1198
Deploy Preview for testcontainers-dotnet ready!
| Name | Link |
|---|---|
| Latest commit | 4091134bf871c2ca4488e42a4d7d22e3bdf4eea8 |
| Latest deploy log | https://app.netlify.com/sites/testcontainers-dotnet/deploys/666b3ada4fd5e20008f954d2 |
| Deploy Preview | https://deploy-preview-1200--testcontainers-dotnet.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
@tnc1997's container not support TLS and his module uses the insecure port of that container.
As had been previously discussed,
ConfigurationClient refuses to connect to a URI endpoint over an unsecured HTTP connection.
The Azure SDK (and specifically ConfigurationClient) enforce TLS everywhere.
The official CosmosDB emulator offers an endpoint for fetching the PEM certificate to make this requirement a little easier to deal with, however there are more issues in play such as the app config domain and scope/identity requirements which had also been discussed extensively.
I worked very hard to [address these issues in my Testcontainers module](https://github.com/goldsam/azure-app-configuration-emulator/blob/9adc28f418b7ae9030c90f859f77fa137aa46311/src/AzureAppConfigurationEmulator.Test containers/AzureAppConfigurationEmulatorBuilder.cs#L71-L91), and was quite disappointed that you discarded that work.
@tnc1997 I had spent a LOT of time contributing to your project throughout our discussions addressing these matters, so this feels like a bit of a slap in the face.
@tnc1997's container not support TLS and his module uses the insecure port of that container.
As had been previously discussed,
ConfigurationClient refuses to connect to a URI endpoint over an unsecured HTTP connection.
The Azure SDK (and specifically
ConfigurationClient) enforce TLS everywhere.The official CosmosDB emulator offers an endpoint for fetching the PEM certificate to make this requirement a little easier to deal with, however there are more issues in play such as the app config domain and scope/identity requirements which had also been discussed extensively.
I worked very hard to [address these issues in my Testcontainers module](https://github.com/goldsam/azure-app-configuration-emulator/blob/9adc28f418b7ae9030c90f859f77fa137aa46311/src/AzureAppConfigurationEmulator.Test containers/AzureAppConfigurationEmulatorBuilder.cs#L71-L91), and was quite disappointed that you discarded that work.
@tnc1997 I had spent a LOT of time contributing to your project throughout our discussions addressing these matters, so this feels like a bit of a slap in the face.
Hi @goldsam, I appreciate your concerns.
Firstly, the Azure SDK does not enforce TLS everywhere, for example the storage clients to name a few:
- https://github.com/testcontainers/testcontainers-dotnet/blob/develop/src/Testcontainers.Azurite/AzuriteContainer.cs#L30-L32
- https://github.com/testcontainers/testcontainers-dotnet/blob/develop/tests/Testcontainers.Azurite.Tests/AzuriteContainerTest.cs
Secondly, a test has been added that shows that the ConfigurationClient works fine without TLS:
- https://github.com/tnc1997/testcontainers-dotnet/blob/feat/1198/tests/Testcontainers.AzureAppConfiguration.Tests/AzureAppConfigurationContainerTest.cs
Connecting to the emulator using HMAC authentication is the recommended approach, hence the GetConnectionString convenience method which aligns with other Testcontainer modules in this repository such as Azurite. Extending the out-of-the-box container that is returned to align with custom requirements is very easy due to the ContainerBuilder interface:
.crt & .key
var container = new AzureAppConfigurationBuilder()
.WithEnvironment("ASPNETCORE_HTTP_PORTS", "8080")
.WithEnvironment("ASPNETCORE_HTTPS_PORTS", "8081")
.WithEnvironment("Kestrel__Certificates__Default__Path", "/usr/local/share/azureappconfigurationemulator/emulator.crt")
.WithEnvironment("Kestrel__Certificates__Default__KeyPath", "/usr/local/share/azureappconfigurationemulator/emulator.key")
.WithResourceMapping("emulator.crt", "/usr/local/share/azureappconfigurationemulator/emulator.crt")
.WithResourceMapping("emulator.key", "/usr/local/share/azureappconfigurationemulator/emulator.key")
.Build();
.pfx
var container = new AzureAppConfigurationBuilder()
.WithEnvironment("ASPNETCORE_HTTP_PORTS", "8080")
.WithEnvironment("ASPNETCORE_HTTPS_PORTS", "8081")
.WithEnvironment("Kestrel__Certificates__Default__Password", "password")
.WithEnvironment("Kestrel__Certificates__Default__Path", "/root/.aspnet/https/aspnetapp.pfx")
.WithResourceMapping("aspnetapp.pfx", "/root/.aspnet/https/aspnetapp.pfx")
.Build();
Microsoft already has an official solution for the App Configuration Emulator. This implementation should use the official image.
@NelsonBN tnc1997/azure-app-configuration-emulator predates Microsoft's tool by a while and is more feature complete. To say Microsoft already has an official solution incorrectly insinuates that is predates and is of a higher quality - both of which are false claims.
Sorry, I'm having a bit of trouble following. I'm not familiar with these implementations, and it looks like Microsoft provides an Azure App Configuration Emulator. Is there any comparison of the features available?
Of course, relying on an image that's maintained by the vendor and behaves like the production version is definitely what we're aiming for. I'm not saying one implementation is better than the other.
This Pull Request was opened some time ago and since then Microsoft has released an official emulator for Azure App Configuration although it is currently missing some of the features that are available in the unofficial emulator.