Description
Library name and version
Azure.Provisioning v1.0.0
Describe the bug
While working on adding existing resource support to Aspire, I realized that there's spooky behavior in the provisioning APIs that appears to mark certain properties as read-only properties by overloading the IsOutput
value. This makes it difficult to set certain configuration options, like Redis's IsAccessKeyAuthenticationDisabled
property. This requires that we implement workarounds like the following to support mutating these:
/// <remarks>
/// The provisioning APIs will mark the IsAccessKeyAuthenticationDisabled as `ReadOnly` after the
/// `IsExistingResource` property is set, making it impossible to configure the
/// `IsAccessKeyAuthenticationDisabled` property in our usual flows. This is a workaround to
/// allow us to set the property on existing resources.
/// </remarks>
private sealed class ExistingCdkRedisResource : CdkRedisResource
{
public ExistingCdkRedisResource(string bicepIdentifier, bool isAccessKeyAuthenticationDisabled, string? resourceVersion = null) : base(bicepIdentifier, resourceVersion)
{
IsAccessKeyAuthenticationDisabled = isAccessKeyAuthenticationDisabled;
IsExistingResource = true;
}
}
There's a case to be made about these properties being immutable for existing resources but the overloading of output/read-only feels awkward here.
Expected behavior
Properties are not erroneously marked as output properties for existing resources.
Actual behavior
Exceptions thrown when setting certain properties as follows:
var resource = RedisResource.FromExisting("name");
resource.IsAccessKeyAuthenticationDisabled = false; // Invalid
Reproduction Steps
var resource = RedisResource.FromExisting("name");
resource.IsAccessKeyAuthenticationDisabled = false; // Invalid
Environment
No response