During the ARM template deployment, I get this error related to pre-existing Event Hub Name space - Sec-2-eventhub:
The deployment 'Deployment-rg-vms-20220208010117' failed with error(s). Showing 1 out of 1 error(s). Status Message: Can not perform requested operation on nested resource. | Parent resource 'Sec-2-eventhub' not found. (Code:ParentResourceNotFound)
This is my azuredeploy.json
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachineName": {
"type": "string",
"metadata": {
"description": " Virtual Machine Name"
}
},
"virtualMachineSize": {
"type": "string",
"metadata": {
"description": "Virtual Machine Size"
},
"allowedValues": [
"Standard_B1ls",
"Standard_DS1",
"Standard_DS2",
"Standard_DS3",
"Standard_DS4"
],
"defaultValue": "Standard_B1ls"
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "Virtual Machine Administrator User Name"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Virtual Machine Administrator Password"
}
},
"eventHubNameSpace": {
"type": "string",
"metadata": {
"description": "Existing Event Hub"
}
},
"diagStorageAccount": {
"type": "string",
"metadata": {
"description": "Existing Storage Account Name"
}
},
"virtualNetworkRG": {
"type": "string",
"metadata": {
"description": "Virtual Network Resource Group Name"
}
},
"virtualNetworkName": {
"type": "string",
"metadata": {
"description": "Existing Virtual Network Name"
}
},
"subnetName": {
"type": "string",
"metadata": {
"description": "Existing Subnet name"
}
}
},
"variables": {
"eventHubHubName": "logs",
"eventHubPolicyName": "SendKey",
"storageAccountType": "Premium_LRS",
"vnetID": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', parameters('virtualNetworkRG'), '/providers/Microsoft.Network/virtualNetworks/',parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
"publicIpAddressName": "[concat(parameters('virtualMachineName'), '-pip')]",
"networkInterfaceName": "[concat(parameters('virtualMachineName'), '-nic')]"
},
"resources": [
{
"name": "[parameters('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2019-03-01",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Network/networkInterfaces/', variables('networkInterfaceName'))]"
],
"identity": {
"type": "SystemAssigned"
},
"properties": {
"osProfile": {
"computerName": "[parameters('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"windowsConfiguration": {
"provisionVmAgent": true
}
},
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2019-Datacenter",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage",
"managedDisk": {
"storageAccountType": "[variables('storageAccountType')]"
}
},
"dataDisks": [
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]"
}
]
}
}
},
{
"name": "[variables('networkInterfaceName')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Network/publicIpAddresses', variables('publicIpAddressName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateIPAllocationMethod": "Dynamic",
"publicIpAddress": {
"id": "[resourceId(resourceGroup().Name,'Microsoft.Network/publicIpAddresses', variables('publicIpAddressName'))]"
}
}
}
]
}
},
{
"name": "[variables('publicIpAddressName')]",
"type": "Microsoft.Network/publicIpAddresses",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"properties": {
"publicIpAllocationMethod": "dynamic"
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"apiVersion": "2019-03-01",
"name": "[concat(parameters('virtualMachineName'), '/IaaSDiagnostics')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]"
],
"properties": {
"autoUpgradeMinorVersion": true,
"publisher": "Microsoft.Azure.Diagnostics",
"type": "IaaSDiagnostics",
"typeHandlerVersion": "1.5",
"settings": {
"WadCfg": {
"DiagnosticMonitorConfiguration": {
"overallQuotaInMB": 4096,
"DiagnosticInfrastructureLogs": {
"scheduledTransferLogLevelFilter": "Error"
},
"Directories": {
"scheduledTransferPeriod": "PT1M",
"IISLogs": {
"containerName": "wad-iis-logfiles"
},
"FailedRequestLogs": {
"containerName": "wad-failedrequestlogs"
}
},
"PerformanceCounters": {
"scheduledTransferPeriod": "PT1M",
"sinks": "EventHub",
"PerformanceCounterConfiguration": [
{
"counterSpecifier": "\\Memory\\Available Bytes",
"sampleRate": "PT15S"
},
{
"counterSpecifier": "\\Memory\\% Committed Bytes In Use",
"sampleRate": "PT15S"
},
{
"counterSpecifier": "\\Memory\\Committed Bytes",
"sampleRate": "PT15S"
},
{
"counterSpecifier": "\\Processor(_total)\\% Processor Time",
"sampleRate": "PT15S"
}
]
},
"WindowsEventLog": {
"scheduledTransferPeriod": "PT1M",
"sinks": "EventHub",
"DataSource": [
{
"name": "Application!Error"
},
{
"name": "Security!*"
},
{
"name": "System!Critical"
}
]
},
"Logs": {
"scheduledTransferPeriod": "PT1M",
"scheduledTransferLogLevelFilter": "Error"
}
},
"SinksConfig": {
"Sink": [
{
"name": "EventHub",
"EventHub": {
"Url": "[concat('https://', parameters('eventHubNameSpace'), '.servicebus.windows.net/', variables('eventHubHubName'))]",
"SharedAccessKeyName": "[variables('eventHubPolicyName')]"
}
}
]
}
},
"StorageAccount": "[parameters('diagStorageAccount')]"
},
"protectedSettings": {
"storageAccountName": "[parameters('diagStorageAccount')]",
"storageAccountKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('diagStorageAccount')), '2019-04-01').keys[0].value]",
"storageAccountEndPoint": "https://core.windows.net",
"EventHub": {
"Url": "[concat('https://', parameters('eventHubNameSpace'), '.servicebus.windows.net/', variables('eventHubHubName'))]",
"SharedAccessKeyName": "[variables('eventHubPolicyName')]",
"SharedAccessKey": "[listKeys(resourceId(concat('Microsoft.EventHub/namespaces{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachineName": {
"value": "winvm"
},
"virtualMachineSize": {
"value": "Standard_B1ls"
},
"adminUsername": {
"value": "myadmuser"
},
"adminPassword": {
"value": "SomeS3curePassword!"
},
"eventHubNameSpace": {
"value": "Sec-2-eventhub"
},
"diagStorageAccount": {
"value": "sec2ehdiag01"
},
"virtualNetworkRG": {
"value": "vnets-rg"
},
"virtualNetworkName": {
"value": "core-net"
}
}
}
and this is my azuredepy.paramenters.json file
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachineName": {
"value": "winvm"
},
"virtualMachineSize": {
"value": "Standard_B1ls"
},
"adminUsername": {
"value": "myadmuser"
},
"adminPassword": {
"value": "SomeS3curePassword!"
},
"eventHubNameSpace": {
"value": "Sec-2-eventhub"
},
"diagStorageAccount": {
"value": "sec2ehdiag01"
},
"virtualNetworkRG": {
"value": "vnets-rg"
},
"virtualNetworkName": {
"value": "core-net"
}
}
}
what could be wrong?