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).
Related
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 .
I am struggling to execute az cli commands related to resource groups.
I have set the correct subscription.
I can list the resource group with the command 'az group list'.
But I get errors when referring to the resource group in a command where mysql is involved, for example:
C:>az mysql server show --resource-group HHDevelopment --name hh-dev-test
The Resource 'Microsoft.DBforMySQL/servers/hh-dev-test' under resource group 'HHDevelopment' was not found.
When I login to Azure portal, I can access the mysql server and the databases without any problem.
What should I do to get it working on the Azure Command Line Interface?
When I ask for a list databases in the resource group, I get a json formatted list of alert rules, components and databases.
So, the group and the database exists.
An example from the list is the following:
C:> az resource list --resource-group HHDevelopment`
`[...]
{
"id": "/subscriptions/0c839bc3-c0c3-470b-a62f-c4998fe000c0/resourceGroups/HHDevelopment/providers/Microsoft.Sql/servers/hh-dev-test/databases/Elp.Arrangement.10",
"identity": null,
"kind": "v12.0,user",
"location": "westeurope",
"managedBy": null,
"name": "hh-dev-test/Elp.Arrangement.10",
"plan": null,
"properties": null,
"resourceGroup": "HHDevelopment",
"sku": {
"capacity": 5,
"family": null,
"model": null,
"name": "Basic",
"size": null,
"tier": "Basic"
},
"tags": null,
"type": "Microsoft.Sql/servers/databases"
},
[...]
why do you think it exists? you show that it finds some sql server in that resource group, whilst your command is looking for mysql server, i just you just mistakenly try to get sql server resource using command for mysql server
I suppose you are looking for these: https://learn.microsoft.com/en-us/cli/azure/sql/server?view=azure-cli-latest
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.
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.
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.