I have a webapp with a slot. Both should have the app setting name DISABLE_CRON. The webapp (production slot) should have this setting set to false and the slot should have the setting set to true. I would like to do this with ARM-template. The webapp have many appsettings such as database name, database login username and password etc. I want all of those settings to be in a variable so I don't have to write them one time for the webapp and one time for the slot. Basically I just want to change the value to true on the slot and keep all other settings the same.
"variables": {
"appName": "[concat(parameters('applicationName'),'-',parameters('environment'),'-app')]",
"hostingPlanName": "[concat(parameters('applicationName'),'-',parameters('environment'),'-plan')]",
"dbserverName": "[concat('onlinecampaignsites-',parameters('environment'),'-dbs-01')]",
"connectionString": "[concat('Database=', parameters('applicationName'), ';Data Source=', concat('onlinecampaignsites-',parameters('environment'),'-dbs-01'),'.mysql.database.azure.com;User Id=',parameters('administratorLogin'),'#',concat('onlinecampaignsites-',parameters('environment'),'-dbs-01'),';Password=',parameters('administratorLoginPassword'))]",
"appInsightsName": "[concat(parameters('applicationName'),'-',parameters('environment'),'-appIn')]",
"databaseName": "[parameters('applicationName')]",
"storageName": "[concat(parameters('applicationName'),parameters('environment'),'stg')]",
"serverFarmResourceGroup": "[resourceGroup().name]",
"subscriptionId": "[subscription().subscriptionId]",
"containerName01": "[concat(parameters('applicationName'),'-',parameters('environment'),'-uploads')]",
"staging": "staging",
"appsettings": {
"DISABLE_CRON": "false",
"HEJSAN": "Den vann den"
}
},
"resources": [
{
"name": "[variables('appname')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"apiVersion": "2018-02-01",
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
],
"properties": {
"siteConfig": {
"appSettings": [
{
"name": "DISABLE_CRON",
"value": "true"
}
]
},
"hostNameSslStates":"[concat('{\"name\": \"',parameters('customDomain'),'\", \"sslState\": \"Disabled\", \"virtualIP\": null, \"thumbprint\": null, \"toUpdate\": null,\"hostType\": \"Standard\"}')]",
"serverFarmId": "[concat('/subscriptions/', variables('subscriptionId'),'/resourcegroups/', variables('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]",
"hostingEnvironment": "",
"httpsOnly": true
},
"resources": [
{
"apiVersion": "2018-02-01",
"name": "slotconfignames",
"type": "config",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('appName'))]"
],
"properties": {
"appSettingNames": [ "DISABLE_CRON" ]
}
},
{
"apiVersion": "2018-02-01",
"type": "config",
"name": "appsettings",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('appName'))]"
],
"properties": "[variables('appsettings')]"
}
]
},
{
"apiVersion": "2018-02-01",
"type": "Microsoft.Web/sites/slots",
"name": "[concat(variables('appName'), '/', variables('staging'))]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('appName'))]",
"[concat('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]"
],
"properties": {},
"resources": [
{
"apiVersion": "2018-02-01",
"type": "config",
"name": "appsettings",
"dependsOn": [
"[resourceId('Microsoft.Web/sites/slots', variables('appName'), variables('staging'))]"
],
"properties": "[variables('appsettings')]"
}
]
},
In the ARM-template example there are two appsettings. It does not work to set the DISABLE_CRON to true, I just wanted to show that with this example.
Related
I am trying to set diagnostic settings for my Azure sql database via ARM template, However the diagnostic part (nested under database resource) is failing because the type 'providers/diagnosticsetting' is invalid.
Error:
New-AzResourceGroupDeployment : 4:56:26 AM - Resource providers/diagnosticSettings 'monitor' failed with message '{
"error": {
"code": "InvalidResourceNamespace",
"message": "The resource namespace 'providers' is invalid."
}
}'
ARM Template snippet:
"resources": [
{
"type": "Microsoft.Sql/servers",
"apiVersion": "2020-02-02-preview",
"name": "[parameters('serverName')]",
"location": "[parameters('location')]",
"identity": {
"type": "SystemAssigned"
},
"properties": {
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
"version": "12.0"
},
"resources": [
{
"type": "databases",
"apiVersion": "2020-02-02-preview",
"name": "[parameters('sqlDBName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Standard",
"tier": "Standard"
},
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', concat(parameters('serverName')))]"
],
"resources": [
{
"type": "transparentDataEncryption",
"apiVersion": "2017-03-01-preview",
"name": "current",
"dependsOn": [
"[parameters('sqlDBName')]"
],
"properties": {
"status": "Enabled"
}
},
{
"type": "providers/diagnosticSettings",
"apiVersion": "2017-05-01-preview",
"name": "monitor",
"dependsOn": [
"[parameters('sqlDBName')]"
],
"properties": {
"workspaceId": "[parameters('logAnalyticsWorkspaceIdForGlobalDiagnosticSetting')]",
"logs": [
],
"metrics": [
]
}
},
{
"type": "vulnerabilityAssessments",
"apiVersion": "2020-02-02-preview",
"name": "default",
"dependsOn": [
"[parameters('sqlDBName')]"
],
"properties": {
"storageContainerPath": "[parameters('storageContainerPathForVulnerabilityAssesment')]",
"storageAccountAccessKey": "[parameters('storageAccountAccessKeyForVulnerabilityAssesment')]",
"recurringScans": {
"isEnabled": true,
"emailSubscriptionAdmins": false,
"emails": []
}
}
}
]
}
]
},
{
"type": "Microsoft.Sql/servers/firewallRules",
"apiVersion": "2020-02-02-preview",
"name": "[concat(parameters('serverName'), '/AllowAzureIPs')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
],
"properties": {
"endIpAddress": "0.0.0.0",
"startIpAddress": "0.0.0.0"
}
},
{
"type": "Microsoft.Sql/servers/administrators",
"apiVersion": "2020-08-01-preview",
"name": "[concat(parameters('serverName'), '/ActiveDirectory')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
],
"properties": {
"administratorType": "ActiveDirectory",
"login": "[parameters('azureActiveDirectoryAdminLogin')]",
"sid": "[parameters('azureActiveDirectoryAdminSid')]",
"tenantId": "[parameters('azureActiveDirectoryAdminTenantId')]"
}
},
{
"type": "Microsoft.Sql/servers/securityAlertPolicies",
"apiVersion": "2020-08-01-preview",
"name": "[concat(parameters('serverName'), '/Default')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
],
"properties": {
"state": "Enabled",
"emailAccountAdmins": false
}
},
{
"type": "Microsoft.Sql/servers/auditingSettings",
"apiVersion": "2020-08-01-preview",
"name": "[concat(parameters('serverName'), '/Default')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
],
"properties": {
"isDevopsAuditEnabled": false,
"retentionDays": 0,
"auditActionsAndGroups": [
"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP",
"FAILED_DATABASE_AUTHENTICATION_GROUP",
"BATCH_COMPLETED_GROUP"
],
"isStorageSecondaryKeyInUse": false,
"isAzureMonitorTargetEnabled": false,
"state": "Enabled",
"storageEndpoint": "[reference(resourceId(parameters('centralMonitoringResourceGroup'), 'Microsoft.Storage/storageAccounts', parameters('centralMonitoringStorageAccountName')), '2019-06-01').PrimaryEndpoints.Blob]",
"storageAccountAccessKey": "[parameters('centralMonitoringStorageAccountAccessKey')]",
"storageAccountSubscriptionId": "[parameters('centralMonitoringStorageAccountSubscriptionId')]"
}
},
{
"type": "Microsoft.Sql/servers/vulnerabilityAssessments",
"apiVersion": "2020-08-01-preview",
"name": "[concat(parameters('serverName'), '/Default')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]",
"[concat('Microsoft.Sql/servers/', parameters('serverName'), '/securityAlertPolicies/Default')]"
],
"properties": {
"storageContainerPath": "[parameters('storageContainerPathForVulnerabilityAssesment')]",
"storageAccountAccessKey": "[parameters('storageAccountAccessKeyForVulnerabilityAssesment')]",
"recurringScans": {
"isEnabled": true,
"emailSubscriptionAdmins": false,
"emails": []
}
}
},
{
"type": "Microsoft.Sql/servers/encryptionProtector",
"apiVersion": "2020-08-01-preview",
"name": "[concat(parameters('serverName'), '/current')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
],
"kind": "servicemanaged",
"properties": {
"serverKeyName": "ServiceManaged",
"serverKeyType": "ServiceManaged",
"autoRotationEnabled": false
}
},
{
"type": "Microsoft.Sql/servers/connectionPolicies",
"apiVersion": "2014-04-01",
"name": "[concat(parameters('serverName'), '/ConnectionPolicies')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
],
"properties": {
"connectionType": "[parameters('connectionType')]"
}
}
]
The ARM template requirements for importing/applying a site extension nuget package is clear, but requires a public feed. What method should be used with a private Azure DevOps artifact nuget feed that requires authentication?
Template snippet below works with public feed, but returns Invalid feed Uri when private.
{
"name": "[variables('webAppName')]",
"type": "Microsoft.Web/sites",
"kind": "app",
"location": "[resourceGroup().location]",
"apiVersion": "2015-08-01",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('appServiceName'))]"
],
"tags": {},
"properties": {
"name": "[variables('webAppName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServiceName'))]",
"siteConfig": {
"WindowsFxVersion": "[parameters('windowsFxVersion')]",
"ftpsState": "Disabled",
"phpVersion": "Off",
"use32BitWorkerProcess": false,
"http20Enabled": true,
"minTlsVersion": "1.2",
"defaultDocuments": [
"index.html"
]
},
"hostNames": [
"[concat('wa-', parameters('baseAppName'),'.azurewebsites.net')]"
],
"siteProperties": {
"metadata": null,
"properties": [{
"name": "LinuxFxVersion",
"value": null
},
{
"name": "WindowsFxVersion",
"value": "DOTNETCORE|2.2"
}
],
"appSettings": null,
"httpsOnly": true
},
"availabilityState": "Normal",
"sslCertificates": null,
"httpsOnly": true,
"csrs": [],
"cers": null,
"siteMode": null,
"enabledHostNames": [
"[concat('wa-', parameters('baseAppName'),'.azurewebsites.net')]",
"[concat('wa-', parameters('baseAppName'),'.scm.azurewebsites.net')]"
]
},
"resources": [{
"name": "appsettings",
"type": "config",
"apiVersion": "2015-08-01",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('webAppName'))]"
],
"properties": {
"SCM_SITEEXTENSIONS_FEED_URL": "[PRIVATE NUGET FEED]"
}
},
{
"apiVersion": "2015-08-01",
"name": "[SITE EXTENSION NAME]",
"type": "siteextensions",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('webAppName'))]",
"[concat(resourceId('Microsoft.Web/Sites', variables('webAppName')),'/config/appsettings')]"
],
"properties": {}
}
]
}
It's not possible to use a private endpoint in a template deployment at this time.
I'm struggling with a ARM deployment script for my node.js application. If I point to a repo with an MVC application it all works fine, but not using an node.js app.
Are there any specific settings for node.js sites?
Here is the resource part of my script:
{
"apiVersion": "2015-08-01",
"name": "[parameters('nodeName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('nodeName'))]": "Resource",
"displayName": "Website"
},
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', parameters('nodeName'))]"
],
"resources": [
{
"apiVersion": "2015-08-01",
"name": "web",
"type": "sourcecontrols",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', concat(parameters('nodeName')))]"
],
"properties": {
"repoUrl": "https://github.com/microServiceBus/microservicebus.node.git",
"branch": "master",
"IsManualIntegration": true
}
}
],
"properties": {
"name": "[parameters('nodeName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('nodeName'))]",
"siteConfig": {
"appSettings": [
{
"Name": "hubUri",
"Value": "[parameters('hubUri')]"
},
{
"Name": "nodeName",
"Value": "[parameters('nodeName')]"
},
{
"Name": "organizationaId",
"Value": "[parameters('organizationaId')]"
}
]
}
}
}
The issue was that the name of the repo had a dot in it (microservicebus.node.git). I believe the bug is fixed or is going to be fixed soon.
I am using ARM template to perform Import Azure SQL databases from bacpac files storing on my storage account.
However I am getting unexpected Bad Request error from Azure.
The same ARM template has been working fine just a few weeks ago.
When I try to do the Import Databases in the new Azure portal manually, I am also getting error from Azure, but they didn't specify the error detail.
I have tried for three different locations: Southeast Asia, North Europe and Central US but all have failed.
Below is my ARM template portion for database server and database import.
{
"type": "Microsoft.Sql/servers",
"apiVersion": "2014-04-01-preview",
"properties": {
"administratorLogin": "[parameters('dbLogin')]",
"administratorLoginPassword": "[parameters('dbPassword')]",
"version": "12.0"
},
"name": "[parameters('sqlServerName')]",
"location": "[resourceGroup().location]",
"resources": [
{
"type": "firewallrules",
"apiVersion": "2014-04-01-preview",
"properties": {
"endIpAddress": "0.0.0.0",
"startIpAddress": "0.0.0.0"
},
"name": "AllowAllWindowsAzureIps",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlServerName'))]"
]
},
{
"type": "databases",
"apiVersion": "2014-04-01-preview",
"properties": {
"edition": "[parameters('databaseEdition')]",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"maxSizeBytes": "[parameters('maxDatabaseSize')]",
"requestedServiceObjectiveId": "[parameters('dbServiceObjectiveLevel')]"
},
"name": "[parameters('webDatabaseName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlServerName'))]"
],
"resources": [
{
"type": "extensions",
"apiVersion": "2014-04-01-preview",
"properties": {
"operationMode": "Import",
"storageKey": "[parameters('bacpacStorageKey')]",
"storageKeyType": "Primary",
"administratorLogin": "[parameters('dbLogin')]",
"administratorLoginPassword": "[parameters('dbPassword')]",
"storageUri": "[parameters('webBacpacUrl')]"
},
"name": "Import",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers/databases', parameters('sqlServerName'), parameters('webDatabaseName'))]"
]
}
]
},
{
"type": "databases",
"apiVersion": "2014-04-01-preview",
"properties": {
"edition": "[parameters('databaseEdition')]",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"maxSizeBytes": "[parameters('maxDatabaseSize')]",
"requestedServiceObjectiveId": "[parameters('dbServiceObjectiveLevel')]"
},
"name": "[parameters('coreDatbaseName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlServerName'))]"
],
"resources": [
{
"type": "extensions",
"apiVersion": "2014-04-01-preview",
"properties": {
"operationMode": "Import",
"storageKey": "[parameters('bacpacStorageKey')]",
"storageKeyType": "Primary",
"administratorLogin": "[parameters('dbLogin')]",
"administratorLoginPassword": "[parameters('dbPassword')]",
"storageUri": "[parameters('coreBacpacUrl')]"
},
"name": "Import",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers/databases', parameters('sqlServerName'), parameters('coreDatbaseName'))]"
]
}
]
},
{
"type": "databases",
"apiVersion": "2014-04-01-preview",
"properties": {
"edition": "[parameters('databaseEdition')]",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"maxSizeBytes": "[parameters('maxDatabaseSize')]",
"requestedServiceObjectiveId": "[parameters('dbServiceObjectiveLevel')]"
},
"name": "[parameters('mastrerDatabaseName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('sqlServerName'))]"
],
"resources": [
{
"type": "extensions",
"apiVersion": "2014-04-01-preview",
"properties": {
"operationMode": "Import",
"storageKey": "[parameters('bacpacStorageKey')]",
"storageKeyType": "Primary",
"administratorLogin": "[parameters('dbLogin')]",
"administratorLoginPassword": "[parameters('dbPassword')]",
"storageUri": "[parameters('masterBacpacUrl')]"
},
"name": "Import",
"location": "[resourceGroup().location]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers/databases', parameters('sqlServerName'), parameters('mastrerDatabaseName'))]"
]
}
]
}
]
}
The error from Azure portal for my ARM deployment:
Any help or advice is appreciated!
Note: I have suspected this could be due to platform issue but there is no issue reported for the past few days on the locations I tried based on the
Azure status history
Verified with Microsoft Azure Support and they confirmed this is a platform issue.
Update:
The issue is verified resolved after Microsoft resolved the platform issue related to Import Database.
I am trying to automate website deployment using the Azure Resource Manager. Website creation and code deployment is working fine, but I am unable to attach the new site to an existing Web Hosting plan.
I am using the 2015-08-01 API and from different examples I think that this template should work (it does not...):
The deployment fails at "Microsoft.Web/sites/config" and the site is beeing assigned a new default free hosting plan.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"siteName": {
"type": "string"
},
"subscriptionId": {
"type": "string"
},
"setting1": {
"type": "string"
},
"setting2": {
"type": "string"
}
},
"resources": [
{
"apiVersion": "2015-08-01",
"type": "Microsoft.Web/sites",
"name": "[parameters('siteName')]",
"location": "[resourceGroup().location]",
"properties": {
"serverFarmId ": "/subscriptions/xxxxxx/resourceGroups/xxxxxx/providers/Microsoft.Web/serverfarms/xxxxxx"
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "web",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
],
"properties": {
"phpVersion": "off",
"netFrameworkVersion": "v4.6",
"use32BitWorkerProcess": false,
"webSocketsEnabled": true,
"alwaysOn": true,
"requestTracingEnabled": false,
"httpLoggingEnabled": false,
"logsDirectorySizeLimit": 40,
"detailedErrorLoggingEnabled": false,
"appSettings": [
{
"Name": "setting1",
"Value": "Value1"
},
{
"Name": "setting2",
"Value": "Value2"
}
]
}
},
{
"apiVersion": "2015-08-01",
"type": "extensions",
"name": "MSDeploy",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('siteName'))]"
],
"properties": {
"packageUri": "xxxxxxxx",
"dbType": "None",
"connectionString": ""
}
}
]
}
],
"outputs": {
"siteUri": {
"type": "string",
"value": "[concat('http://',reference(resourceId('Microsoft.Web/sites', parameters('siteName'))).hostNames[0])]"
}
}
}
I ended up falling back to the 2014-06-01 API and with some adjustments to the script, was able to do what I wanted.
Providing the script for future references.
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"siteName": {
"type": "string"
},
"subscriptionId": {
"type": "string"
},
"hostingPlanName": {
"type": "string"
},
"setting1": {
"type": "string"
},
"setting2": {
"type": "string"
}
},
"resources": [
{
"apiVersion": "2014-06-01",
"type": "Microsoft.Web/sites",
"name": "[parameters('siteName')]",
"location": "[resourceGroup().location]",
"dependsOn": [
],
"properties": {
"name": "[parameters('siteName')]",
"serverFarm": "[parameters('hostingPlanName')]"
},
"resources": [
{
"apiVersion": "2014-06-01",
"name": "web",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]",
"[concat('Microsoft.Web/Sites/', parameters('siteName'), '/Extensions/MSDeploy')]"
],
"properties": {
"phpVersion": "off",
"netFrameworkVersion": "v4.6",
"use32BitWorkerProcess": false,
"webSocketsEnabled": true,
"alwaysOn": true,
"requestTracingEnabled": false,
"httpLoggingEnabled": false,
"logsDirectorySizeLimit": 40,
"detailedErrorLoggingEnabled": false
}
},
{
"apiVersion": "2014-11-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]",
"[concat('Microsoft.Web/Sites/', parameters('siteName'), '/Extensions/MSDeploy')]"
],
"properties": {
"Setting1": "[parameters('setting1')]",
"Setting2": "[parameters('setting2')]"
}
},
{
"apiVersion": "2015-08-01",
"type": "extensions",
"name": "MSDeploy",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
],
"properties": {
"packageUri": "https://xxxxx.zip",
"dbType": "None",
"connectionString": ""
}
}
]
}
]
}