Provisioning WebApp and SQL using Azure Resource Manager

Azure Resource Manager (ARM) template is a great way to create new resources. Some of the advantages of using ARM are


  • Container for a given set of resources.
  • Permissions can be assigned at the container level.
  • Easier to remove the set of resources by simply deleting the resource group.
Q: How do you script the creation of resources using ARM?
A: The main command to use here is New-AzureRmResourceGroupDeployment. You pass the template file and template parameter file to this command. Azure will then create the given resource group and use the template file to create resources defined in the template file. Azure will use the parameters file to overwrite any values if defined. This uses JSON file, which makes it relatively easily to manage.

Following is the process used to script out deploying SQL Server, Web App with a hosting plan and Microsoft Insight. Just FYI some of the JSON has been borrowed from other examples on the Web. Describing Microsoft Insight is out of scope of this document .

Deploy.ps1 

<#

 .SYNOPSIS
    Deploys a template to Azure

 .DESCRIPTION
    Deploys an Azure Resource Manager template
 .PARAMETER XmlDocument
    Optional, path to the file containing various paramters.

#>

param(
 [Parameter(Mandatory=$false,HelpMessage="Specify the path to an XML document.")][System.String]$XmlDocument = 'AzureRoot.xml',
 [string]
 $env = "DEV"
)

<#
.SYNOPSIS
    Registers RPs
#>
Function RegisterRP {
    Param(
        [string]$ResourceProviderNamespace
    )

    Write-Host "Registering resource provider '$ResourceProviderNamespace'";
    Register-AzureRmResourceProvider -ProviderNamespace $ResourceProviderNamespace -Force;
}

If(!(Get-Module Azure))
    {
        Import-Module Azure -ErrorAction Stop
    }
    
    $dir = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
    
    # Get Xml document
    Try 
    {
        [System.Xml.XmlDocument]$xml = Get-Content ($dir + '\' + $XmlDocument)
    }
    Catch
    {
        Write-Error "Unable to get Xml Document"
    }
    
    # Remove existing Azure accounts to ensure proper subscription is used
    Write-Warning "Removing existing Azure accounts"
    Get-AzureAccount | Where-Object {$_.id -ne $xml.Configuration.$env.Azure.Account -and $_.type -eq 'User'} | ForEach-Object { Remove-AzureAccount $_.ID }

    # Add Azure account (launches GUI to authenticate against Azure)
# Temp Commented
#Add-AzureAccount
$account = Get-AzureAccount -Name $xml.Configuration.$env.Azure.Account
    $subscriptionId = Get-AzureSubscription -SubscriptionId $xml.Configuration.$env.Azure.SubscriptionID
$resourceGroupName = $xml.Configuration.$env.Resource.Name
$resourceGroupLocation = $xml.Configuration.$env.Resource.Location
$templateFilePath = $dir + '\' + $xml.Configuration.$env.Files.TemplateFilePath
$parametersFilePath = $dir + '\' + $xml.Configuration.$env.Files.ParametersFilePath
#******************************************************************************
# Script body
# Execution begins here
#******************************************************************************
$ErrorActionPreference = "Stop"

# sign in
#Write-Host "Logging in...";
Login-AzureRmAccount;

# select subscription
#Write-Host "Selecting subscription '$subscriptionId'";
#Select-AzureRmSubscription -SubscriptionID $subscriptionId;

# Register RPs
$resourceProviders = @("microsoft.insights","microsoft.sql","microsoft.web");
if($resourceProviders.length) {
    Write-Host "Registering resource providers"
    foreach($resourceProvider in $resourceProviders) {
        RegisterRP($resourceProvider);
    }
}

#Create or check for existing resource group
$resourceGroup = Get-AzureRmResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue
if(!$resourceGroup)
{
    Write-Host "Resource group '$resourceGroupName' does not exist. To create a new resource group, please enter a location.";
    if(!$resourceGroupLocation) {
        $resourceGroupLocation = Read-Host "resourceGroupLocation";
    }
    Write-Host "Creating resource group '$resourceGroupName' in location '$resourceGroupLocation'";
    New-AzureRmResourceGroup -Name $resourceGroupName -Location $resourceGroupLocation
}
else{
    Write-Host "Using existing resource group '$resourceGroupName'";
}

# Start the deployment
Write-Host "Starting deployment...";
if((-Not ([string]::IsNullOrWhitespace($parametersFilePath))) -and (Test-Path $parametersFilePath)) {
    New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath -TemplateParameterFile $parametersFilePath;
} else {
    New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath;
}

Write-Host "Completed";

Note: A similar power shell script can be downloaded by going to this URL
https://resources.azure.com. The assumption here is that you have manually created a resource group and added all your resources in that group. 

Walk through of  Deploy.ps1

The main logic of the file is to use XML file and JSON file for performing the action in different environments. The power shell starts by looking for a XML file in the same location where the powershell is located.

Here is the XML file it loads:

<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<DEV>
<Azure SubscriptionID="99306-a3c3-493c-af4e-08efss1e" Account="AzureAccount" />
<Resource Name="myresources" Location="East US" DeploymentName="Initial" />
<Files TemplateFilePath="azuredeploy.json" ParametersFilePath="parameters-dev.json"/>
</DEV>
<QA>
<Azure SubscriptionID="19191-a3c3-493c-af4e-0kquwb81e" Account="AzureAccount2" />
<Resource Name="KartikGroup_Alt" Location="East US" DeploymentName="Initial" />
<Files TemplateFilePath="azuredeploy.json" ParametersFilePath="parameters-qa.json"/>
</QA>
<PROD>
<Azure SubscriptionID="9191a-a3c3-493c-af4e-lwjwjww" Account="AzureAccount3" />
<Resource Name="KartikGroup" Location="East US" DeploymentName="Initial" />
<Files TemplateFilePath="azuredeploy.json" ParametersFilePath="parameters.json"/>
</PROD>
</Configuration>

Pay special attention to the all the elements as you can easily change in the XML file to update for a given environment. In the above XML file, I have defined 3 environments with its own set of elements. The script checks for existence of the resource group. If exists, uses that else it creates a new resource group based on the above XML file.

Then, script checks for existence of the path of JSON file and parameters file. These files are also defined in the above XML file.

Write-Host "Starting deployment...";
if((-Not ([string]::IsNullOrWhitespace($parametersFilePath))) -and (Test-Path $parametersFilePath)) {
    New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath -TemplateParameterFile $parametersFilePath;
} else {
    New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateFile $templateFilePath;
}

Here is the Template File that is being used here. I found online this file and modified a little based on my needs. However, the key difference between this and what Azure OOTB gives you is that you can even define your app variables and even time zones. In this JSON file you can define what are the defaults it can use and what are the other permissible values. Those values can be overwritten in the parameters.XML file. Ideally, you will have 1 parameters file for each environment to overwrite environment specific prefixes, variables, app setting variables, connection strings, credentials etc.

AzureDeploy.JSON

{
"$schema" : "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion" : "1.0.0.0",
"parameters" : {
"skuName" : {
"type" : "string",
"defaultValue" : "F1",
"allowedValues" : ["F1",
"D1",
"B1",
"B2",
"B3",
"S1",
"S2",
"S3",
"P1",
"P2",
"P3",
"P4"],
"metadata" : {
"description" : "Describes plan's pricing tier and instance size. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
}
},
"skuCapacity" : {
"type" : "int",
"defaultValue" : 1,
"minValue" : 1,
"allowedValues" : [
0,
1,
2
      ],
"metadata" : {
"description" : "Describes plan's instance count"
}
},
"administratorLogin" : {
"type" : "string",
"metadata" : {
"description" : "The admin user of the SQL Server"
}
},
"administratorLoginPassword" : {
"type" : "securestring",
"metadata" : {
"description" : "The password of the admin user of the SQL Server"
}
},
"databaseName" : {
"type" : "string",
"defaultValue" : "sampledb",
"metadata" : {
"description" : "The name of the new database to create."
}
},
"collation" : {
"type" : "string",
"defaultValue" : "SQL_Latin1_General_CP1_CI_AS",
"metadata" : {
"description" : "The database collation for governing the proper use of characters."
}
},
"edition" : {
"type" : "string",
"defaultValue" : "Basic",
"allowedValues" : ["Basic",
"Standard",
"Premium"],
"metadata" : {
"description" : "The type of database to create."
}
},
"maxSizeBytes" : {
"type" : "string",
"defaultValue" : "1073741824",
"metadata" : {
"description" : "The maximum size, in bytes, for the database"
}
},
"siteLocation" : {
"type" : "string"
},
"serverName" : {
"type" : "string"
},
"siteName" : {
"type" : "string"
},
"serverLocation" : {
"type" : "string"
},
"hostingPlanName" : {
"type" : "string"
},
"company" : {
"type" : "string"
},
"application" : {
"type" : "string"
},
"prefix" : {
"type" : "string"
},
"env" : {
"type" : "string"
},
"requestedServiceObjectiveName" : {
"type" : "string",
"defaultValue" : "Basic",
"allowedValues" : ["Basic",
"S0",
"S1",
"S2",
"P1",
"P2",
"P3"],
"metadata" : {
"description" : "Describes the performance level for Edition"
}
},
"appSetting1" : {
"type" : "string",
"defaultValue" : "--",
"metadata" : {
"description" : "Custom App Settings Key"
}
},
"appSetting2" : {
"type" : "string",
"defaultValue" : "--",
"metadata" : {
"description" : "Custom App Settings Key"
}
},
"appSetting3" : {
"type" : "string",
"defaultValue" : "--",
"metadata" : {
"description" : "Custom App Settings Key"
}
},
"use32BitWorkerProcess" : {
"type" : "bool",
"defaultValue" : true,
"metadata" : {
"description" : "To use 32 bit processor or not. Note: Free tier only supports 32 bit."
}
}
},
"variables" : {
"hostingPlanName" : "[concat(parameters('prefix'), '-', parameters('company'), '-', 'hostingplan', '-', parameters('application'), '-', parameters('env'), '-', uniqueString(resourceGroup().id))]",
"webSiteName" : "[concat(parameters('prefix'), '-', parameters('company'), '-','WebSite', '-', parameters('application'), '-', parameters('env'), '-', uniqueString(resourceGroup().id))]",
"sqlserverName" : "[concat(parameters('prefix'), '-', parameters('company'), '-', 'sqlserver', '-', parameters('application'), '-', parameters('env'), '-', uniqueString(resourceGroup().id))]",
"databaseName" : "[concat(parameters('prefix'), '-', parameters('company'), '-', 'SQLDB', '-', parameters('application'), '-', parameters('env'))]",
"appInsights" : "[concat(parameters('prefix'), '-', parameters('company'), '-','AppInsight', '-', parameters('application'), '-', parameters('env'), '-', uniqueString(resourceGroup().id))]",
"autoScaleSettings" : "[concat(parameters('prefix'), '-', parameters('company'), '-','AutoScaleSettings', '-', parameters('application'), '-', parameters('env'))]",
"siteProperties" : {
"phpVersion" : "5.5",
"netFrameworkVersion" : "v4.6",
"use32BitWorkerProcess" : "[parameters('use32BitWorkerProcess')]",
/* 64-bit platform */
"webSocketsEnabled" : false,
"alwaysOn" : false,
"requestTracingEnabled" : true,
/* Failed request tracing, aka 'freb' */
"httpLoggingEnabled" : true,
/* IIS logs (aka Web server logging) */
"logsDirectorySizeLimit" : 40,
/* 40 MB limit for IIS logs */
"detailedErrorLoggingEnabled" : true,
/* Detailed error messages  */
"remoteDebuggingEnabled" : true,
"remoteDebuggingVersion" : "VS2015",

"defaultDocuments" : [
"index.html",
"hostingstart.html"
]
}
},
"resources" : [{
"name" : "[variables('sqlserverName')]",
"type" : "Microsoft.Sql/servers",
"location" : "[resourceGroup().location]",
"tags" : {
"displayName" : "SqlServer"
},
"apiVersion" : "2014-04-01-preview",
"properties" : {
"administratorLogin" : "[parameters('administratorLogin')]",
"administratorLoginPassword" : "[parameters('administratorLoginPassword')]"
},
"resources" : [{
"name" : "[variables('databaseName')]",
"type" : "databases",
"location" : "[resourceGroup().location]",
"tags" : {
"displayName" : "Database"
},
"apiVersion" : "2014-04-01-preview",
"dependsOn" : ["[variables('sqlserverName')]"],
"properties" : {
"edition" : "[parameters('edition')]",
"collation" : "[parameters('collation')]",
"maxSizeBytes" : "[parameters('maxSizeBytes')]",
"requestedServiceObjectiveName" : "[parameters('requestedServiceObjectiveName')]"
}
}, {
"type" : "firewallrules",
"apiVersion" : "2014-04-01-preview",
"dependsOn" : ["[variables('sqlserverName')]"],
"location" : "[resourceGroup().location]",
"name" : "AllowAllWindowsAzureIps",
"properties" : {
"endIpAddress" : "0.0.0.0",
"startIpAddress" : "0.0.0.0"
}
}
]
}, {
"apiVersion" : "2015-08-01",
"name" : "[variables('hostingPlanName')]",
"type" : "Microsoft.Web/serverfarms",
"location" : "[resourceGroup().location]",
"tags" : {
"displayName" : "HostingPlan"
},
"sku" : {
"name" : "[parameters('skuName')]",
"capacity" : "[parameters('skuCapacity')]"
},
"properties" : {
"name" : "[variables('hostingPlanName')]"
}
}, {
"apiVersion" : "2015-08-01",
"name" : "[variables('webSiteName')]",
"type" : "Microsoft.Web/sites",
"location" : "[resourceGroup().location]",
"dependsOn" : ["[variables('hostingPlanName')]"],
"tags" : {
"[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName')))]" : "empty",
"displayName" : "Website"
},
"properties" : {
"name" : "[variables('webSiteName')]",
"serverFarmId" : "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]"
},
"resources" : [{
"apiVersion" : "2015-08-01",
"name" : "web",
"type" : "config",
"dependsOn" : ["[variables('webSiteName')]"],
"properties" : "[variables('siteProperties')]"
}, {
"apiVersion" : "2015-08-01",
"name" : "appsettings",
"type" : "config",
"dependsOn" : ["[variables('webSiteName')]"],
"properties" : {
"AppSettingKey1" : "[parameters('appSetting1')]",
"AppSettingKey2" : "[parameters('appSetting2')]",
"AppSettingKey3" : "[parameters('appSetting3')]",
"WEBSITE_TIME_ZONE" : "Pacific Standard Time"
}
}, {
"apiVersion" : "2015-08-01",
"type" : "config",
"name" : "connectionstrings",
"dependsOn" : ["[variables('webSiteName')]"],
"properties" : {
"DefaultConnection" : {
"value" : "[concat('Data Source=tcp:', reference(concat('Microsoft.Sql/servers/', variables('sqlserverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', variables('databaseName'), ';User Id=', parameters('administratorLogin'), '@', variables('sqlserverName'), ';Password=', parameters('administratorLoginPassword'), ';')]",
"type" : "SQLServer"
},
"ConnString1" : {
"value" : "My custom connection string",
"type" : "Custom"
}
}
}
]
}, {
"apiVersion" : "2014-04-01",
"name" : "[concat(variables('hostingPlanName'), '-', resourceGroup().name)]",
"type" : "Microsoft.Insights/autoscalesettings",
"location" : "[resourceGroup().location]",
"tags" : {
"[concat('hidden-link:', resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName')))]" : "Resource",
"displayName" : "AutoScaleSettings"
},
"dependsOn" : ["[variables('hostingPlanName')]"],
"properties" : {
"profiles" : [{
"name" : "Default",
"capacity" : {
"minimum" : 1,
"maximum" : 2,
"default" : 1
},
"rules" : [{
"metricTrigger" : {
"metricName" : "CpuPercentage",
"metricResourceUri" : "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"timeGrain" : "PT1M",
"statistic" : "Average",
"timeWindow" : "PT10M",
"timeAggregation" : "Average",
"operator" : "GreaterThan",
"threshold" : 80.0
},
"scaleAction" : {
"direction" : "Increase",
"type" : "ChangeCount",
"value" : 1,
"cooldown" : "PT10M"
}
}, {
"metricTrigger" : {
"metricName" : "CpuPercentage",
"metricResourceUri" : "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"timeGrain" : "PT1M",
"statistic" : "Average",
"timeWindow" : "PT1H",
"timeAggregation" : "Average",
"operator" : "LessThan",
"threshold" : 60.0
},
"scaleAction" : {
"direction" : "Decrease",
"type" : "ChangeCount",
"value" : 1,
"cooldown" : "PT1H"
}
}
]
}
],
"enabled" : false,
"name" : "[concat(variables('hostingPlanName'), '-', resourceGroup().name)]",
"targetResourceUri" : "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]"
}
}, {
"apiVersion" : "2014-04-01",
"name" : "[concat('ServerErrors ', variables('webSiteName'))]",
"type" : "Microsoft.Insights/alertrules",
"location" : "[resourceGroup().location]",
"dependsOn" : ["[variables('webSiteName')]"],
"tags" : {
"[concat('hidden-link:', resourceId('Microsoft.Web/sites', variables('webSiteName')))]" : "Resource",
"displayName" : "ServerErrorsAlertRule"
},
"properties" : {
"name" : "[concat('ServerErrors ', variables('webSiteName'))]",
"description" : "[concat(variables('webSiteName'), ' has some server errors, status code 5xx.')]",
"isEnabled" : false,
"condition" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri" : "[resourceId('Microsoft.Web/sites', variables('webSiteName'))]",
"metricName" : "Http5xx"
},
"operator" : "GreaterThan",
"threshold" : 0.0,
"windowSize" : "PT5M"
},
"action" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners" : true,
"customEmails" : []
}
}
}, {
"apiVersion" : "2014-04-01",
"name" : "[concat('ForbiddenRequests ', variables('webSiteName'))]",
"type" : "Microsoft.Insights/alertrules",
"location" : "[resourceGroup().location]",
"dependsOn" : ["[variables('webSiteName')]"],
"tags" : {
"[concat('hidden-link:', resourceId('Microsoft.Web/sites', variables('webSiteName')))]" : "Resource",
"displayName" : "ForbiddenRequestsAlertRule"
},
"properties" : {
"name" : "[concat('ForbiddenRequests ', variables('webSiteName'))]",
"description" : "[concat(variables('webSiteName'), ' has some requests that are forbidden, status code 403.')]",
"isEnabled" : false,
"condition" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri" : "[resourceId('Microsoft.Web/sites', variables('webSiteName'))]",
"metricName" : "Http403"
},
"operator" : "GreaterThan",
"threshold" : 0,
"windowSize" : "PT5M"
},
"action" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners" : true,
"customEmails" : []
}
}
}, {
"apiVersion" : "2014-04-01",
"name" : "[concat('CPUHigh ', variables('hostingPlanName'))]",
"type" : "Microsoft.Insights/alertrules",
"location" : "[resourceGroup().location]",
"dependsOn" : ["[variables('hostingPlanName')]"],
"tags" : {
"[concat('hidden-link:', resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName')))]" : "Resource",
"displayName" : "CPUHighAlertRule"
},
"properties" : {
"name" : "[concat('CPUHigh ', variables('hostingPlanName'))]",
"description" : "[concat('The average CPU is high across all the instances of ', variables('hostingPlanName'))]",
"isEnabled" : false,
"condition" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri" : "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"metricName" : "CpuPercentage"
},
"operator" : "GreaterThan",
"threshold" : 90,
"windowSize" : "PT15M"
},
"action" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners" : true,
"customEmails" : []
}
}
}, {
"apiVersion" : "2014-04-01",
"name" : "[variables('autoScaleSettings')]",
"type" : "Microsoft.Insights/alertrules",
"location" : "[resourceGroup().location]",
"dependsOn" : ["[variables('hostingPlanName')]"],
"tags" : {
"[concat('hidden-link:', resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName')))]" : "Resource",
"displayName" : "AutoScaleSettings"
},
"properties" : {
"name" : "[variables('autoScaleSettings')]",
"description" : "[concat('The HTTP queue for the instances of ', variables('hostingPlanName'), ' has a large number of pending requests.')]",
"isEnabled" : false,
"condition" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
"dataSource" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
"resourceUri" : "[concat(resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', variables('hostingPlanName'))]",
"metricName" : "HttpQueueLength"
},
"operator" : "GreaterThan",
"threshold" : 100.0,
"windowSize" : "PT5M"
},
"action" : {
"odata.type" : "Microsoft.Azure.Management.Insights.Models.RuleEmailAction",
"sendToServiceOwners" : true,
"customEmails" : []
}
}
}, {
"apiVersion" : "2014-04-01",
"name" : "[variables('appInsights')]",
"type" : "Microsoft.Insights/components",
"location" : "Central US",
"dependsOn" : ["[variables('webSiteName')]"],
"tags" : {
"[concat('hidden-link:', resourceId('Microsoft.Web/sites', variables('webSiteName')))]" : "Resource",
"displayName" : "AppInsightsComponent"
},
"properties" : {
"ApplicationId" : "[variables('webSiteName')]"
}
}
],
"outputs" : {
"siteUri" : {
"type" : "string",
"value" : "[reference(concat('Microsoft.Web/sites/', variables('webSiteName')), '2015-08-01').hostnames[0]]"
},
"sqlSvrFqdn" : {
"type" : "string",
"value" : "[reference(concat('Microsoft.Sql/servers/', variables('sqlserverName'))).fullyQualifiedDomainName]"
}
}
}

In the above file, pay special attention to how the variables are defined. I have copied the same section here again for ease.

"variables" : {
"hostingPlanName" : "[concat(parameters('prefix'), '-', parameters('company'), '-', 'hostingplan', '-', parameters('application'), '-', parameters('env'), '-', uniqueString(resourceGroup().id))]",
"webSiteName" : "[concat(parameters('prefix'), '-', parameters('company'), '-','WebSite', '-', parameters('application'), '-', parameters('env'), '-', uniqueString(resourceGroup().id))]",
"sqlserverName" : "[concat(parameters('prefix'), '-', parameters('company'), '-', 'sqlserver', '-', parameters('application'), '-', parameters('env'), '-', uniqueString(resourceGroup().id))]",
"databaseName" : "[concat(parameters('prefix'), '-', parameters('company'), '-', 'SQLDB', '-', parameters('application'), '-', parameters('env'))]",
"appInsights" : "[concat(parameters('prefix'), '-', parameters('company'), '-','AppInsight', '-', parameters('application'), '-', parameters('env'), '-', uniqueString(resourceGroup().id))]",
"autoScaleSettings" : "[concat(parameters('prefix'), '-', parameters('company'), '-','AutoScaleSettings', '-', parameters('application'), '-', parameters('env'))]",
"siteProperties" : {
"phpVersion" : "5.5",
"netFrameworkVersion" : "v4.6",
"use32BitWorkerProcess" : "[parameters('use32BitWorkerProcess')]",
/* 64-bit platform */
"webSocketsEnabled" : false,
"alwaysOn" : false,
"requestTracingEnabled" : true,
/* Failed request tracing, aka 'freb' */
"httpLoggingEnabled" : true,
/* IIS logs (aka Web server logging) */
"logsDirectorySizeLimit" : 40,
/* 40 MB limit for IIS logs */
"detailedErrorLoggingEnabled" : true,
/* Detailed error messages  */
"remoteDebuggingEnabled" : true,
"remoteDebuggingVersion" : "VS2015",

"defaultDocuments" : [
"index.html",
"hostingstart.html"
]
}
},


Here is my parameters-dev.JSON file with all the overwrites. 

Parameters-dev.JSON

{
"$schema" : "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion" : "1.0.0.0",
"parameters" : {
"company" : {
"value" : "kacompany"
},
"application" : {
"value" : "app"
},
"prefix" : {
"value" : "pf"
},
"env" : {
"value" : "dev"
},
"hostingPlanName" : {
"value" : "DevHostingPlan"
},
"serverLocation" : {
"value" : "Central US"
},
"serverName" : {
"value" : "myserver"
},
"administratorLogin" : {
"value" : "admin"
},
"administratorLoginPassword" : {
"value" : "p@ssword!!"
},
"databaseName" : {
"value" : "sqldbname"
},
"siteLocation" : {
"value" : "Central US"
},
"siteName" : {
"value" : "general"
},
"skuname" : {
"value" : "F1"
},
"requestedServiceObjectiveName" : {
"value" : "Basic"
},
"skuCapacity" : {
"value" : 1
},
"appSetting2" : {
"value" : "My Overwrite Test"
},
"use32BitWorkerProcess" : {
"value" : true
}
}
}




Once you run the power shell, you should see an output similar to the below image.


In the portal, you will see an output like this




Additional Notes:
  • Use lowercase variables as SQL Server requires names to be lower case. If not, then need to create SQL server specific variables separately.
  • Resource Group can also be deleted via REST 

Comments

  1. It was really a nice post and i was really impressed by reading this
    Azure Online Training Bangalore

    ReplyDelete
  2. Offshore Hosting By #1 Trusted Offshore Host Provider. https://offshorededicated.net/

    ReplyDelete
  3. Webcare360 Provides you safe and secure cheap Offshore Hosting Best offshore hosting and best offshore Hosting with 99.9% Up time Guarantee, with Ddos protection.

    ReplyDelete
  4. very useful information, the post shared was very nice.
    DevOps Course Videos

    ReplyDelete

Post a Comment