Skip to content

[BUG] Unable to set mutable properties on CosmosDB/Redis when modeled as existing resources #48352

Open
@captainsafia

Description

@captainsafia

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

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.Provisioningcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions