skip to Main Content

I am trying to deploy two virtual machines to the same virtual network. But I am running into a rather obscure error. I am using Azure Bicep which then builds an ARM template. The ARM template is then added to Octopus Deploy in which I am using the ‘DEPLOY AN AZURE RESOURCE MANAGER TEMPLATE’

Status: Conflict 
March 28th 2023 16:28:37Error
Provisioning State: Failed 
March 28th 2023 16:28:37Error
Status Message: {"status":"Failed","error":{"code":"DeploymentFailed","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.","target":null,"details":[{"code":"MethodNotAllowed","message":"{rn  "Message": "The requested resource does not support http method 'PUT'."rn}","target":null,"details":null,"additionalInfo":null}],"additionalInfo":null}} 

Before this error occurs the following resources are already created for the first VM:

In the VNet module

  • Microsoft.Network/networkSecurityGroups@2021-02-01
  • Microsoft.Network/virtualNetworks@2021-02-01

In the VM module

  • Microsoft.Storage/storageAccounts@2021-04-01
  • Microsoft.Network/publicIPAddresses@2021-02-01
  • Microsoft.Network/networkInterfaces@2021-02-01

The VM it self and all the things for the 2nd VM are not created.
I am using modules to create the VMs and the virtual network + Security group. My best guess is that something is wrong with the virtual machine or the network interface, since after the network interface it throws the error. When I remove the VM creation from the VM module everything is created except for the VM. All the resources are in the same resource group. Any ideas?

Full files here (bit different since I tried some other things to see if they would work) https://github.com/TimChermin/azure-bicep

resource nic_name 'Microsoft.Network/networkInterfaces@2021-02-01' = {
  name: nic.name
  location: location
  tags: {
    vendor: tags.vendor
    description: tags.description
  }
  properties: {
    ipConfigurations: [
      {
        name: nic.ipConfigName
        properties: {
          privateIPAllocationMethod: 'Dynamic'
          publicIPAddress: {
            id: publicIPAddressName.id
          }
          subnet: {
            id: '${vnetNameId}/subnets/${subnetName}'
          }
        }
      }
    ]
  }
  dependsOn: [
  ]
}

resource vm 'Microsoft.Compute/virtualMachines@2021-04-01' = {
  name: vmName
  location: location
  tags: {
    vendor: tags.vendor
    description: tags.description
  }
  properties: {
    hardwareProfile: {
      vmSize: vmSize
    }
    osProfile: {
      computerName: vmName
      adminUsername: vmAdminUsername
      adminPassword: vmAdminPassword
    }
    storageProfile: {
      imageReference: {
        publisher: 'MicrosoftWindowsServer'
        offer: 'WindowsServer'
        sku: '2016-Datacenter'
        version: 'latest'
      }
      osDisk: {
        createOption: 'FromImage'
        caching: 'ReadWrite'
        managedDisk: {
          storageAccountType: 'Standard_LRS'
        }
      }
    }
    networkProfile: {
      networkInterfaces: [
        {
          id: nic_name.id
        }
      ]
    }
    diagnosticsProfile: {
      bootDiagnostics: {
        enabled: true
        storageUri: diagnostics_storageAccount_name.properties.primaryEndpoints.blob
      }
    }
  }
  dependsOn: [
    diagnostics_storageAccount_name

  ]
}

Called like this

module networkModule 'modules/networkmodule.bicep' = {
  name: 'NetworkModule'
  params: {
    vnetName: vnet.name
    subnetName: vnet.subnet.name
    vnetAddress: vnet.addressPrefix
    subnetAddress: vnet.subnet.addressPrefix
  }
}

module vmModuleOne 'modules/testing.bicep' = {
  name: 'vmModuleOne'
  params: {
    vmAdminUsername: vmAdminUsername
    vmAdminPassword: vmAdminPassword
    vmDnsName: vmDnsName
    vmSize: vmSize
    vnetNameId: networkModule.outputs.vnetId
    subnetName: vnet.subnet.name
    diagnostics: diagnosticsOne
    vmName: vmName
    nameSpace: nameSpaceOne
  }
  dependsOn:[
    networkModule
  ]
}

module vmModuleTwo 'modules/testing.bicep' = {
  name: 'vmModuleTwo'
  params: {
    vmAdminUsername: vmAdminUsername
    vmAdminPassword: vmAdminPassword
    vmDnsName: vmDnsNameTwo
    vmSize: vmSize
    vnetNameId: networkModule.outputs.vnetId
    subnetName: vnet.subnet.name
    diagnostics: diagnosticsTwo
    vmName: vmNameTwo
    nameSpace: nameSpaceTwo
  }
  dependsOn:[
    networkModule
    vmModuleOne
  ]
}

2

Answers


  1. Chosen as BEST ANSWER

    So I made a mistake in the Octopus configuration. I used runbooks to deploy the ARM template. The problem was that my variables were not used because I assigned roles to them. Which are not used in runbooks.


  2. Need to check below:

    • The virtual network and network security group must be created before the virtual machines that will use them.

    • The "dependsOn" property will be used to specify resource dependencies. Verify that the dependencies are correctly given.

    • Verify that the user or service principal who is deploying it has the required permissions to create the resources.

    Refer this for any other deployment errors.

    I used the same code provided by you in github. I’ve received few errors related to dns name. But later on, it worked fine with only minor changes to the user information in my environment and successfully deployed all of the given resources.

    Cause of the error: Given Dns already existed in other location.

    enter image description here

    After modifying that, I got the successful deployment as shown:

    enter image description here

    Portal:

    enter image description here

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search