Azure / bicep-types-az

Bicep type definitions for ARM resources
MIT License
86 stars 27 forks source link

VM Bicep rerun bicep for creating a VM - getting errors upon second run #1902

Open gsuttie opened 1 year ago

gsuttie commented 1 year ago

Bicep version Bicep CLI version 0.22.6 (d62b94db31)

Describe the bug When I run my bicep script it deploys a vm, disk, nic and a public ip and seems to work with no errors. If I just rerun the script the whatif shows Moficications to the pip and nic

To Reproduce Run the script then run it agai straight after - so rerun the following script

module jumpboxVM 'modules/Microsoft.Compute/virtualMachines/deploy.bicep' = if (deployVM) {
  scope: resourceGroup(vmRg)
  name: 'vm-service'
  params: {
    name: 'vm-service'
    adminUsername: localAdmin
    adminPassword: localAdminPassword
    imageReference: {
      publisher: 'MicrosoftWindowsServer'
      offer: 'WindowsServer'
      sku: '2022-Datacenter'
      version: 'latest'
    }
    nicConfigurations: [
      {
          nicSuffix: '-nic'
          ipConfigurations: [
            {
              name: 'ipConfig'
              subnetResourceId: '/subscriptions/${subscriptionID}/resourceGroups/${networkRG}/providers/Microsoft.Network/virtualNetworks/${vnetName}/subnets/backendsubnet'
              pipconfiguration: {
                publicIpNameSuffix: '-pip'
              }
              privateIPAllocationMethod: 'Dynamic'
            }
          ]
      }
    ]
    osDisk: {
      name: 'osdisk'
      caching: 'ReadWrite'
      createOption: 'FromImage'
      diskSizeGB: 128
      managedDisk: {
        storageAccountType: 'Standard_LRS'
      }
    }
    osType: 'Windows'
    vmSize: 'Standard_D2as_v5'
    location: location
    tags: tags
    encryptionAtHost: false
  }
  dependsOn: [
    createRG
  ]
}

Additional context Add any other context about the problem here.

This is the error I see

{"status":"Failed","error":{"code":"DeploymentFailed","target":"/subscriptions//providers/Microsoft.Resources/deployments/","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"ResourceDeploymentFailure","target":"/subscriptions//resourceGroups/rg-vm--prd-weu/providers/Microsoft.Resources/deployments/vm-service","message":"The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'.","details":[{"code":"DeploymentFailed","target":"/subscriptions//resourceGroups/rg-vm--prd-weu/providers/Microsoft.Resources/deployments/vm-service","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"ResourceDeploymentFailure","target":"/subscriptions//resourceGroups/rg-vm--prd-weu/providers/Microsoft.Resources/deployments/zir2tz2afng2a-VM-Nic-0","message":"The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'.","details":[{"code":"DeploymentFailed","target":"/subscriptions//resourceGroups/rg-vm--prd-weu/providers/Microsoft.Resources/deployments/-VM-Nic-0","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"ResourceDeploymentFailure","target":"/subscriptions//resourceGroups/rg-vm--prd-weu/providers/Microsoft.Resources/deployments/-VM-Nic-0-publicIP-0","message":"The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'.","details":[{"code":"DeploymentFailed","target":"/subscriptions//resourceGroups/rg-vm--prd-weu/providers/Microsoft.Resources/deployments/-VM-Nic-0-publicIP-0","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"ResourceDeploymentFailure","target":"/subscriptions//resourceGroups/rg-vm--prd-weu/providers/Microsoft.Network/publicIPAddresses/vm-service-pip","message":"The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'.","details":[{"code":"InternalServerError","message":"An error occurred.","details":[]}]}]}]}]}]}]}]}]}} Something went wrong. Please check the error and try again.

coolhome commented 1 year ago

It looks like subscriptionID never resolved.

Unrelated note you may want to update bicep cli - that version is from 2020.

gsuttie commented 1 year ago

Very odd as I always keep Bicep AZ CLI up-to-date and when i try to update it just does nothing. Not sure why its showing that version and or not updating.

Bicep CLI version 0.22.6 (d62b94db31) - odd that it just started working after typing this!

gsuttie commented 1 year ago

Tried several things and still no luck

gsuttie commented 1 year ago

It only happens when im using a public ip address - if i remove that I can update without errors.

alex-frankel commented 1 year ago

Any time you see "Internal Server Error" it is a bug in the services error handling logic and the next step is to open a support case. Can you try opening a case with the Virtual Machines team?

In parallel, it'd be good to get the full repro including the param declarations and the module definition.

microsoft-github-policy-service[bot] commented 8 months ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @TravisCragg-MSFT, @nikhilpatel909, @sandeepraichura, @hilaryw29, @GabstaMSFT. Please see https://aka.ms/biceptypesinfo for troubleshooting help.