Getting error property not allowed | osdisk.name in azure bicep
Hi All, I recently deployed windows vm using azure bicep .Today i have added some rules in nsg & try to re run the bicep file getting error .
Getting error property not allowed | osdisk.name in azure bicep
Azure Virtual Machines
-
Anveshreddy Nimmala 2,950 Reputation points • Microsoft Vendor
2024-05-16T12:48:40.8933333+00:00 Hello Satish B,
Welcome to microsoft Q&A, thankyou for posting your query.
Remove or comment out the
osDisk.name
property in your Bicep file if you have it defined.no name property is avail for OsDisk
osDisk: { createOption: 'FromImage' managedDisk: { storageAccountType: 'Standard_LRS' }
Ensure that the changes made to the Network Security Group (NSG) rules are correctly formatted and compliant with the ARM schema
resource nsg 'Microsoft.Network/networkSecurityGroups@2021-02-01' = { name: 'myNSG' location: resourceGroup().location properties: { securityRules: [ { name: 'allow-ssh' properties: { priority: 1000 direction: 'Inbound' access: 'Allow' protocol: 'Tcp' sourcePortRange: '*' destinationPortRange: '22' sourceAddressPrefix: '*' destinationAddressPrefix: '*' } } // Add more rules as needed ] } }
Hope this helps you
-
Satish B 25 Reputation points
2024-05-16T13:00:34.2533333+00:00 Hi
please find my code below. still getting error.
osDisk: { createOption: 'fromImage' deleteOption: 'Delete' diskSizeGB: 128 managedDisk: { storageAccountType: 'Premium_LRS' } }
-
Anveshreddy Nimmala 2,950 Reputation points • Microsoft Vendor
2024-05-17T04:15:55.8633333+00:00 Hello Sathish,
Can you please provide whole code used while Deploying and also code used for adding NSG.
-
Satish B 25 Reputation points
2024-05-17T06:36:29.0066667+00:00 Hi,
PFA.
param virtualMachineName string
param virtualMachineSize string = 'Standard_D2s_v5'
param existingVirtualNetworkName string
param existingVnetResourceGroup string
param existingSubnetName string
param OSVersion string = '2019-datacenter-smalldisk-g2'
param adminUsername string
param adminPassword string
param location string = resourceGroup().location
var networkInterfaceName = '${virtualMachineName}-nic'
var networkSecurityGroupName = '${virtualMachineName}-nsg'
var networkSecurityGroupRules = []
var publicIpAddressName = '${virtualMachineName}-publicip-${uniqueString(virtualMachineName)}'
var publicIpAddressType = 'Dynamic'
var publicIpAddressSku = 'Basic'
var nsgId = networkSecurityGroup.id
var subnetRef = resourceId(existingVnetResourceGroup, 'Microsoft.Network/virtualNetWorks/subnets', existingVirtualNetworkName, existingSubnetName)
resource publicIpAddress 'Microsoft.Network/publicIPAddresses@2022-01-01' = {
name: publicIpAddressName
location: location
sku: {
name: publicIpAddressSku
}
properties: {
publicIPAllocationMethod: publicIpAddressType
}
}
resource networkSecurityGroup 'Microsoft.Network/networkSecurityGroups@2022-01-01' = {
name: networkSecurityGroupName
location: location
properties: {
securityRules: networkSecurityGroupRules
}
}
resource networkInterface 'Microsoft.Network/networkInterfaces@2022-01-01' = {
name: networkInterfaceName
location: location
properties: {
ipConfigurations: [ { name: 'ipconfig1' properties: { subnet: { id: subnetRef } privateIPAllocationMethod: 'Dynamic' publicIPAddress: { id: publicIpAddress.id } } } ] enableAcceleratedNetworking: true networkSecurityGroup: { id: nsgId }
}
}
resource virtualMachine 'Microsoft.Compute/virtualMachines@2022-03-01' = {
name: virtualMachineName
location: location
properties: {
hardwareProfile: { vmSize: virtualMachineSize } storageProfile: { osDisk: { createOption: 'FromImage' diskSizeGB: 128 managedDisk: { storageAccountType: 'Premium_LRS' } } imageReference: { publisher: 'MicrosoftWindowsServer' offer: 'WindowsServer' sku: OSVersion version: 'latest' } } networkProfile: { networkInterfaces: [ { id: networkInterface.id } ] } osProfile: { computerName: virtualMachineName adminUsername: adminUsername adminPassword: adminPassword windowsConfiguration: { enableAutomaticUpdates: true provisionVMAgent: true } }
}
}
-
Anveshreddy Nimmala 2,950 Reputation points • Microsoft Vendor
2024-05-17T10:08:50.14+00:00 Hello Satish B,
try using module to update the nsg.
https://stackoverflow.com/questions/73568924/assign-nsg-to-vnet-subnet-using-bicep-template
Hope this helps you
-
Satish B 25 Reputation points
2024-05-17T11:30:32.97+00:00 Still Same issue. Issue with OS disk.name . not for NSG module
-
Prrudram-MSFT 22,836 Reputation points
2024-05-20T13:06:17.23+00:00 Hi @Satish B
Changing property 'osDisk.name' is not allowed" is encountered as some properties can't be changed on a deployed resource. When updating a resource, it is suggested that you limit your changes to permitted properties. I sense there is some change that has been made. Is redeploying from scratch an option for you? https://learn.microsoft.com/en-us/azure/azure-resource-manager/troubleshooting/common-deployment-errors
This requires further debugging and is why @Anveshreddy Nimmala suggested logging a support case. I see an answer was posted for your queries on Stack Overflow community for this issue. Did you check that?
https://stackoverflow.com/questions/78484799/osdisk-name-not-allowed-in-azure-bicep
Sign in to comment