Skip to content

Bicep deployment requires extra properties after the site has been deployed from Azure DevOps #516

@laurihelkkula

Description

@laurihelkkula

Describe the bug

When deploying a Static Web Site via Bicep (or ARM), and when the actual site has been deployed via Azure DevOps Pipelines, the Bicep deployment will fail with the error message:

Provider is invalid.  Cannot change the Provider. Please detach your static site first if you wish to use to another deployment provider.

From #495, you can solve this error by setting the provider. In this case, the value needs to be DevOps.

In addition to the provider property, you get similar error message for the properties branch and repositoryUrl.

To Reproduce
Steps to reproduce the behavior:

  1. Create Bicep file (with empty properties object as instructed in Vague error message #477 to get around another error)
  2. Deploy via Bicep
  3. Get the deployment token, create the Azure Pipeline to deploy the site contents, and run it
  4. Deploy via Bicep again
  5. See error

Workaround
Set the properties to the correct values. You can see the expected values e.g. from Azure Portal. From the Static Web App overview, click JSON view to see the values. See the example Bicep file below for an example

Expected behavior
Provider, branch, or repositoryUrl should not have to be set in the Bicep file when the site deployment is not done via GitHub.

Screenshots
Example Bicep deployment command and the error message:
image

Device info (if applicable):
Not applicable.

Additional context
Example Bicep file

param location string = resourceGroup().location
param webappname string = 'mystaticwebsite'

resource webapp 'Microsoft.Web/staticSites@2021-01-15' = {
  name: webappname
  location: location
  //note: must include at least an empty properties object. otherwise you'll get a validation error during deployment
  properties: {
    //uncomment these and set correct values to make deployment succeed
    //provider: 'DevOps'
    //branch: 'the_deployed_branch'
    //repositoryUrl: 'https://<url to git repo in ADO>'
  }
  sku: {
    name: 'Free'
    tier: 'Free'
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions