The specified name is not available Azure EventHub namespace - azure

I have tried to deploy an ARM template with new EventHub Namespace. But it is failing with the BadRequest error, The specified name isn't available.. But the name has not used previously in anything under that resource group. When I tried to create a similar resource manually from the portal it is working fine. So it should not be a privileges' issue. Can anyone suggest my issue here please?
{
"type": "Microsoft.EventHub/namespaces",
"apiVersion": "2021-11-01",
"name": "xxxx-xxxx-xxx-000",
"location": "[variables('location')]",
"sku": {
"name": "Standard",
"tier": "Standard",
"capacity": 1
},
"properties": {
"isAutoInflateEnabled": false,
"maximumThroughputUnits": 0
}
}

We have tried the same in our environment to create an eventhub namespace with name similar to yours and it works fine .
Below is the workaround we followed;
In the same name that we will be trying to deploy through ARM created in portal and then trying to deploy through ARM and got the same issue.
Yes its a known issue we can expect , To ensure that we need to provide the name which is globally unique and not by any resource group ,Not only at your resource group ,this name should not use anywhere(Azure) .
Make sure that if you have created it through portal and trying with ARM again , please delete the previous one if you are owner of that namespace. And try again with same name after deletion.
We have provided the namespace just similar to you to check whether this value is passed or not and it works successfully.
template.json
"resources": [
{
"type": "Microsoft.EventHub/namespaces",
"apiVersion": "2022-01-01-preview",
"name": "[parameters('namespaces_ajletter_test_111_something_name')]",
"location": "Central India",
"sku": {
"name": "Standard",
"tier": "Standard",
"capacity": 1
},
OUTPUT SCREENSHOT FOR REFERENCE:-
For more information please refer the below links:-
MICROSOFT DOCUMENTATION| EventHub ARM EXCEPTION & Create EventHub Namespace using ARM Template .

Related

Update resource group with ARM template - cannot create Linux app service plan

I have a pipeline that is going to update my Azure resource group using an ARM template. In my resource group I have a Linux app service plan. When my pipeline runs I get the following error:
2020-02-24T09:13:47.8665770Z ##[error]The template deployment 'template-20200224-091344-94a5' is not valid according to the validation procedure. The tracking id is 'cba7977a-ed1a-4807-a8bb-d7387bb9eae1'. See inner errors for details.
2020-02-24T09:13:47.8673575Z ##[error]Details:
2020-02-24T09:13:47.8683161Z ##[error]ValidationForResourceFailed: Validation failed for a resource. Check 'Error.Details[0]' for more information. [{"code":"FreeLinuxSkuNotAllowedInResourceGroup","message":"Cannot create a Linux app service plan because there is a limit of 1 free tier linux app service plan per subscription."}]
2020-02-24T09:13:47.8695096Z ##[error]Task failed while creating or updating the template deployment.
I thought that the pipeline should only update my app service plan, but it seems that it is trying to create a new one. So I suppose what happens is that it creates a new one, and then deletes the old. However, it cannot do this because there's a limit of 1 Linux app service plan and one already exists.
So my question is, how can I make my pipeline only overwrite the old app service plan instead of creating a new one and deleting the old?
Here is the resource in the ARM template:
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('serverfarms_project_api_name')]",
"location": "West Europe",
"tags": {
"Environment": "Dev"
},
"sku": {
"name": "F1",
"tier": "Free",
"size": "F1",
"family": "F",
"capacity": 1
},
"kind": "linux",
"properties": {
"perSiteScaling": false,
"maximumElasticWorkerCount": 1,
"isSpot": false,
"reserved": true,
"isXenon": false,
"hyperV": false,
"targetWorkerCount": 0,
"targetWorkerSizeId": 0
}
}
for the arm template to update existing resource - the resource name has to match exactly. that's the only trick. if the name matches - it will update the resource instead of creating a new one with the same name (not that it is possible).

Provision Azure Redis Cache using ARM and specify Access Keys

I try to provision an Azure Redis Cache using an ARM template. This is working as expected with the exception that I can't specify the access keys.
Usually I work with the generated keys which is probably the recommended way - but in this case I wan't to provide thos keys within my deployment (for some legacy reasons).
Q: Is it possible to provide the access keys within an ARM template? Or can I set them after the deployment using PowerShell?
Here is a snippet of my ARM template:
"resources": [
{
"type": "Microsoft.Cache/Redis",
"name": "[parameters('myRedis_name')]",
"apiVersion": "2016-04-01",
"location": "West Europe",
"tags": {},
"properties": {
"redisVersion": "3.2",
"sku": {
"name": "Standard",
"family": "C",
"capacity": 1
},
"enableNonSslPort": false,
"redisConfiguration": {
"maxclients": "1000",
"maxmemory-reserved": "50",
"maxmemory-delta": "50"
}
},
"resources": [],
"dependsOn": []
},
Just like Azure Storage keys (or DocumentDB keys, etc), you have no ability to specify the keys. You may either use what's provided or, at any time, regenerate the keys (either primary or secondary). This is how keys are managed, regardless whether using ARM or the portal. Here's a screengrab where you can see the regen options:
There's no way to enter a specific key of your own.

Since it's not possible to create Blob container in Azure ARM, then how can I enable Archive using ARM?

According to the documentation I can enable the Azure Event Hubs Archive feature using an Azure Resource Manager template. The template takes a blobContainerName argument:
"The blob container where you want your event data be archived."
But afaik it's not possible to create a blob container using an ARM template, then how am I supposed to enable the Archive feature on an Event Hub?
The purpose of the ARM template is to provision everything from scratch, not to manually create some of the resources using the portal.
It wasn't possible before to create containers in your storage account, but this has been changed. New functionality has been added to the ARM template for Storage Accounts which enable you to create containers.
To create a storage account with a container called theNameOfMyContainer, add this to your resources block of the ARM template.
{
"name": "[parameters('storageAccountName')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2018-02-01",
"location": "[resourceGroup().location]",
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"properties": {
"accessTier": "Hot"
},
"resources": [{
"name": "[concat('default/', 'theNameOfMyContainer')]",
"type": "blobServices/containers",
"apiVersion": "2018-03-01-preview",
"dependsOn": [
"[parameters('storageAccountName')]"
],
"properties": {
"publicAccess": "Blob"
}
}]
}
To my knowledge, you can use None, Blob or Container for your publicAccess.
It's still not possible to create Queues and Tables, but hopefull this will be added soon.
Just like you said, there is no way to create a blob in Azure ARM Template, so the only logical answer to this question is: supply existing blob at deployment time. One way to do that would be to create a blob with powershell and pass it as a parameter to ARM Deployment.

How to use a existing Microsoft.Web/serverfarms in a Azure Resource Manager Template?

I want to deploy a website (Microsoft.Web/sites) resource to a existing hosting plan (Microsoft.Web/serverfarms) without having to define the sku, workersize, etc. in the ARM template. It should just use the hosting plan as-is without changing it. But the sku seems to be required for the hosting plan definition and the hosting plan definition seems to be required for the website definition.
At the moment we read the sku of the hosting plan and set it as a parameter in the ARM template, but sometimes it still triggers a scaling operation in azure and restarts all websites on the hosting plan.
The only thing you need in the ARM Template to set the hosting plan is the resourceId of that serverFarm - that's the serverFarmId property below...
"name": "[variables('websiteName')]",
"type": "Microsoft.Web/sites",
"location": "centralus",
"apiVersion": "2015-08-01",
"dependsOn": [ ],
"tags": {
"displayName": "website"
},
"properties": {
"name": "[variables('websiteName')]",
"serverFarmId": "[resourceId(parameters('serverFarmResourceGroupName'), 'Microsoft.Web/serverFarms', parameters('AppSvcPlanName'))]"
}
That's barebones, but it will put a web app into the existing serverFarm.

Autoscaling IaaS VMs in ARM mode from a template

I've created an template-based deployment that over-provisions a number of Linux VMs. I'd like to autoscale them as per classic instances, where Azure will turn on/turn off instances according to CPU load.
Is this possible with ARM mode? And if not, is there a suggested alternative method? The only examples I can find are around using Application Insights and PaaS functionality. I've got a Python app running in Docker on Ubuntu hosts.
For IaaS, you must use virtual machine scale sets to use autoscale, else you need to stick with PaaS (web apps).
For this you would first need to create an availability group for the VMs. The resource decleration in the ARM template looks something like this:
{
"type": "Microsoft.Compute/availabilitySets",
"name": "[variables('availabilitySetName')]",
"apiVersion": "2015-05-01-preview",
"location": "[parameters('location')]",
"properties": {
"platformFaultDomainCount": "2"
}
}
Then for the virtual machine resource the decliration in the ARM Template would look something like this:
{
"apiVersion": "2015-05-01-preview",
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(variables('vmName'), '0')]",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', parameters('newStorageAccountName'))]",
"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'), '0')]",
"[concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]"
],
"properties": {
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]"
},
...},
The quckstart templates are a good ref: https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/201-2-vms-2-FDs-no-resource-loops/azuredeploy.json
Once you have two or more VMs of the same size in an availability set, you would configure autoscale using microsoft.insights/autoscalesettings, which I beleive you referenced in the question. This is done at the cloud service so it will work similar to PaaS... like so:
{
"apiVersion": "2014-04-01",
"name": "[concat(variables('vmName'), '-', resourceGroup().name)]",
"type": "microsoft.insights/autoscalesettings",
"location": "East US",
...},
A pretty good example is here: https://raw.githubusercontent.com/Azure/azure-quickstart-templates/6abc9f320e39d9d75dffb60846e88ab80d3ff33a/201-web-app-sql-database/azuredeploy.json
I also setup autoscale using the portal first and reviewed ARMExplorer to get a better idea of how things should look in my code. ARMExplorer is here: Azure Resource Explorer

Resources