azure-rest-api-specs icon indicating copy to clipboard operation
azure-rest-api-specs copied to clipboard

Static Web Site: The `provider` in `StaticSite` model is not read only

Open magodo opened this issue 3 years ago • 3 comments

Given following static site resource:

GET <REDACTED>/api-version=2021-02-01

Response:

{
    "id": "REDACTED",
    "name": "example",
    "type": "Microsoft.Web/staticSites",
    "location": "West Europe",
    "tags": {
        "foo": "bar"
    },
    "properties": {
        "defaultHostname": "REDACTED",
        "repositoryUrl": "https://github.com/magodo/my-first-static-web-app",
        "branch": "main",
        "customDomains": [],
        "privateEndpointConnections": [],
        "stagingEnvironmentPolicy": "Enabled",
        "allowConfigFileUpdates": true,
        "contentDistributionEndpoint": "https://content-am2.infrastructure.1.azurestaticapps.net",
        "keyVaultReferenceIdentity": "SystemAssigned",
        "userProvidedFunctionApps": [],
        "linkedBackends": null,
        "provider": "Github",
        "enterpriseGradeCdnStatus": "Disabled",
        "publicNetworkAccess": null
    },
    "sku": {
        "name": "Standard",
        "tier": "Standard"
    },
    "identity": {
        "type": "SystemAssigned",
        "tenantId": "REDACTED",
        "principalId": "REDACTED"
    }
}

If I copy the model above and take it as the request body in another PUT, removing the read only properties:

PUT <REDACTED>/api-version=2021-02-01

Request:

{
    "id": "REDACTED",
    "name": "example",
    "type": "Microsoft.Web/staticSites",
    "location": "West Europe",
    "tags": {
        "foo": "bar"
    },
    "properties": {
        "repositoryUrl": "https://github.com/magodo/my-first-static-web-app",
        "branch": "main",
        "stagingEnvironmentPolicy": "Enabled",
        "allowConfigFileUpdates": true
    },
    "sku": {
        "name": "Standard",
        "tier": "Standard"
    },
    "identity": {
        "type": "SystemAssigned",
        "tenantId": "REDACTED",
        "principalId": "REDACTED"
    }
}

The API returns:

{
    "Code": "BadRequest",
    "Message": "Provider is invalid.  Cannot change the Provider. Please detach your static site first if you wish to use to another deployment provider.",
    "Target": null,
    "Details": [
        {
            "Message": "Provider is invalid.  Cannot change the Provider. Please detach your static site first if you wish to use to another deployment provider."
        },
        {
            "Code": "BadRequest"
        },
        {
            "ErrorEntity": {
                "ExtendedCode": "51021",
                "MessageTemplate": "{0} is invalid.  {1}",
                "Parameters": [
                    "Provider",
                    "Cannot change the Provider. Please detach your static site first if you wish to use to another deployment provider."
                ],
                "Code": "BadRequest",
                "Message": "Provider is invalid.  Cannot change the Provider. Please detach your static site first if you wish to use to another deployment provider."
            }
        }
    ],
    "Innererror": null
}

To fix this, I need to add "provider": "Github" in above request. This indicates that either the provider property in the StaticSite model is incorrectly marked as read only, or the service behavior is not expected.

magodo avatar Mar 31 '22 11:03 magodo

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @AzureAppServiceCLI, @antcp.

Issue Details

Given following static site resource:

GET <REDACTED>/api-version=2021-02-01

Response:

{
    "id": "REDACTED",
    "name": "example",
    "type": "Microsoft.Web/staticSites",
    "location": "West Europe",
    "tags": {
        "foo": "bar"
    },
    "properties": {
        "defaultHostname": "REDACTED",
        "repositoryUrl": "https://github.com/magodo/my-first-static-web-app",
        "branch": "main",
        "customDomains": [],
        "privateEndpointConnections": [],
        "stagingEnvironmentPolicy": "Enabled",
        "allowConfigFileUpdates": true,
        "contentDistributionEndpoint": "https://content-am2.infrastructure.1.azurestaticapps.net",
        "keyVaultReferenceIdentity": "SystemAssigned",
        "userProvidedFunctionApps": [],
        "linkedBackends": null,
        "provider": "Github",
        "enterpriseGradeCdnStatus": "Disabled",
        "publicNetworkAccess": null
    },
    "sku": {
        "name": "Standard",
        "tier": "Standard"
    },
    "identity": {
        "type": "SystemAssigned",
        "tenantId": "REDACTED",
        "principalId": "REDACTED"
    }
}

If I copy the model above and take it as the request body in another PUT, removing the read only properties:

PUT <REDACTED>/api-version=2021-02-01

Request:

{
    "id": "REDACTED",
    "name": "example",
    "type": "Microsoft.Web/staticSites",
    "location": "West Europe",
    "tags": {
        "foo": "bar"
    },
    "properties": {
        "repositoryUrl": "https://github.com/magodo/my-first-static-web-app",
        "branch": "main",
        "stagingEnvironmentPolicy": "Enabled",
        "allowConfigFileUpdates": true
    },
    "sku": {
        "name": "Standard",
        "tier": "Standard"
    },
    "identity": {
        "type": "SystemAssigned",
        "tenantId": "REDACTED",
        "principalId": "REDACTED"
    }
}

The API returns:

{
    "Code": "BadRequest",
    "Message": "Provider is invalid.  Cannot change the Provider. Please detach your static site first if you wish to use to another deployment provider.",
    "Target": null,
    "Details": [
        {
            "Message": "Provider is invalid.  Cannot change the Provider. Please detach your static site first if you wish to use to another deployment provider."
        },
        {
            "Code": "BadRequest"
        },
        {
            "ErrorEntity": {
                "ExtendedCode": "51021",
                "MessageTemplate": "{0} is invalid.  {1}",
                "Parameters": [
                    "Provider",
                    "Cannot change the Provider. Please detach your static site first if you wish to use to another deployment provider."
                ],
                "Code": "BadRequest",
                "Message": "Provider is invalid.  Cannot change the Provider. Please detach your static site first if you wish to use to another deployment provider."
            }
        }
    ],
    "Innererror": null
}

To fix this, I need to add "provider": "Github" in above request. This indicates that either the provider property in the StaticSite model is incorrectly marked as read only, or the service behavior is not expected.

Author: magodo
Assignees: -
Labels:

Service Attention, Web Apps, needs-triage

Milestone: -

ghost avatar Apr 02 '22 00:04 ghost

Ping @AzureAppServiceCLI, @antcp, @JackTn

magodo avatar Apr 22 '22 02:04 magodo

Ping @antcp, @JackTn

magodo avatar Jan 10 '23 01:01 magodo