SIF/930/Platform/sitecore-XP1-rep.json

{
    "Parameters": {
        "Package": {
            "Type": "string",
            "Description": "The path to the Web Deploy package to deploy.",
            "DefaultValue": ""
        },
        "LicenseFile": {
            "Type": "string",
            "Description": "The path to the Sitecore license file.",
            "DefaultValue": ".\\License.xml"
        },
        "SSLCert": {
            "Type": "string",
            "Description": "The certificate to use for HTTPS web bindings. Provide the name or the thumbprint. If not provided a certificate will be generated.",
            "DefaultValue": ""
        },
        "SqlDbPrefix": {
            "Type": "string",
            "Description": "The prefix used for all Sql databases.",
            "DefaultValue": ""
        },
        "SiteName": {
            "Type": "string",
            "DefaultValue": "SitecoreReporting",
            "Description": "The name of the site to be deployed."
        },
        "SiteRoot": {
            "Type": "String",
            "Description": "Root folder to install the site to. If left on the default [systemdrive]:\\inetpub\\wwwroot will be used.",
            "DefaultValue": ""
        },
        "SqlCoreUser": {
            "Type": "string",
            "DefaultValue": "coreuser",
            "Description": "The Sql user for the Core connection string in Sitecore."
        },
        "SqlCorePassword": {
            "Type": "string",
            "DefaultValue": "SIF-Default",
            "Description": "The Sql password for the Core connection string in Sitecore."
        },
        "SqlSecurityUser": {
            "Type": "string",
            "DefaultValue": "securityuser",
            "Description": "The Sql user for the Security connection string in Sitecore."
        },
        "SqlSecurityPassword": {
            "Type": "string",
            "DefaultValue": "SIF-Default",
            "Description": "The Sql password for the Security connection string in Sitecore."
        },
        "SqlMasterUser": {
            "Type": "string",
            "DefaultValue": "masteruser",
            "Description": "The Sql user for the Master connection string in Sitecore."
        },
        "SqlMasterPassword": {
            "Type": "string",
            "DefaultValue": "SIF-Default",
            "Description": "The Sql password for the Master connection string in Sitecore."
        },
        "SqlReportingUser": {
            "Type": "string",
            "DefaultValue": "reportinguser",
            "Description": "The Sql user for the Reporting connection string in Sitecore."
        },
        "SqlReportingPassword": {
            "Type": "string",
            "DefaultValue": "SIF-Default",
            "Description": "The Sql password for the Reporting connection string in Sitecore."
        },
        "SqlServer": {
            "Type": "string",
            "DefaultValue": ".\\SQLSERVER",
            "Description": "The Sql Server where databases will be installed."
        },
        "ReportingServiceApiKey": {
            "Type": "string",
            "DefaultValue": "00112233445566778899AABBCCDDEEFF",
            "Description": "The api key to use with the Reporting Service server must be at least 32 characters long. e.g 00112233445566778899AABBCCDDEEFF"
        },
        "HostMappingName": {
            "Type": "string",
            "Reference": "SiteName",
            "Description": "The host mapping name of the site."
        },
        "DnsName": {
            "Type": "string",
            "Reference": "SiteName",
            "Description": "The dns name of the site."
        },
        "PackagesTempLocation": {
            "Type": "String",
            "Description": "Alternative location to save WDP packages. If left on the default $Env:Temp will be used.",
            "DefaultValue": "",
            "Validate": "[TestPath(variable('Package.Download.Location'))]"
        },
        "DownloadLocations": {
            "Type": "String",
            "Description": "File with URI and SHA256 hashes of dynamically downloadable WDPs.",
            "DefaultValue": ".\\downloads.json"
        }
    },
    "Variables": {
        "Sql.Database.Core.Name": "[concat(parameter('SqlDbPrefix'), '_Core')]",
        "Sql.Database.Security.Name": "[concat(parameter('SqlDbPrefix'), '_Core')]",
        "Sql.Database.Master.Name": "[concat(parameter('SqlDbPrefix'), '_Master')]",
        "Sql.Database.Web.Name": "[concat(parameter('SqlDbPrefix'), '_Web')]",
        "Sql.Database.Reporting.Name": "[concat(parameter('SqlDbPrefix'), '_Reporting')]",
        "Sql.Database.Reporting.Password": "[parameter('SqlReportingPassword')]",
        "Sql.Database.Core.Password": "[parameter('SqlCorePassword')]",
        "Sql.Database.Security.Password": "[parameter('SqlSecurityPassword')]",
        "Sql.Database.Master.Password": "[parameter('SqlMasterPassword')]",
         
        "Certificates.Store": "Cert:\\Localmachine\\My",
        "Certificates.Site.Thumbprint": "[GetCertificateThumbprint(parameter('SSLCert'), variable('Certificates.Store'))]",
         
        "Site.Path": "[if(variable('Site.Path.Test'),variable('Site.Path.Default'),variable('Site.Path.Custom'))]",
        "Site.Path.Default": "[joinpath(environment('SystemDrive'), 'inetpub', 'wwwroot', parameter('SiteName'))]",
        "Site.Path.Custom": "[joinpath(parameter('SiteRoot'),parameter('SiteName'))]",
        "Site.Path.Test": "[equal(parameter('SiteRoot'),'')]",
        "Site.DataFolder": "[joinpath(variable('Site.Path'), 'App_Data')]",
         
        "ReportingService.ApiKey": "[parameter('ReportingServiceApiKey')]",
         
        "Packages.DownloadLocations.File": "[ReadJson(parameter('DownloadLocations'))]",
        "Packages.DownloadLocations.File.Test": "[TestPath(Path:Parameter('DownloadLocations'))]",
 
        "Package.Download.Identifier": "sitecore-XP1-rep.json",
        "Package.Download.Location": "[if(variable('Package.Download.Location.Test'),Environment('Temp'),parameter('PackagesTempLocation'))]",
        "Package.Download.Location.Test": "[equal(parameter('PackagesTempLocation'),'')]",
        "Package.Download.Object": "[SelectObject(InputObject:variable('Packages.DownloadLocations.File'),ExpandProperty:variable('Package.Download.Identifier'))]",
        "Package.Download.Uri": "[SelectObject(InputObject:variable('Package.Download.Object'),ExpandProperty:'Uri')]",
        "Package.Download.Hash": "[SelectObject(InputObject:variable('Package.Download.Object'),ExpandProperty:'Hash')]",
        "Package.Download.Path": "[JoinPath(variable('Package.Download.Location'),variable('Package.Download.Filename'))]",
        "Package.Download.Document": "[SplitPath(Path:variable('Package.Download.Uri'),Leaf:true)]",
        "Package.Download.Filename": "[Split(String:variable('Package.Download.Document'),Characters:'?')]",
 
        "Package": "[if(parameter('Package'),parameter('Package'),variable('Package.Download.Path'))]",
        "Package.Available": "[or(variable('Package.Provided'),not(variable('Packages.DownloadLocations.File.Test')))]",
        "Package.Provided": "[if(parameter('Package'),parameter('Package'),'')]"
    },
    "Register": {
        "ConfigFunction": {
            "TestPath": "Test-Path",
            "SelectObject": "Select-Object",
            "SplitPath": "Split-Path",
            "GetVariable": "Get-Variable"
        },
        "Tasks": {
            "RemoveItem": "Remove-Item"
        }
    },
    "Tasks": {
        "DownloadWDP": {
            "Description": "Download the WDP and verifies it against the stored hash.",
            "Type": "DownloadFile",
            "Params": {
                "SourceUri": "[variable('Package.Download.URI')]",
                "DestinationPath": "[variable('Package.Download.Path')]",
                "Hash": "[variable('Package.Download.Hash')]"
            },
            "Skip": "[variable('Package.Available')]"
        },
        "CreatePaths": {
            "Description": "Ensure the destination path for the site exists.",
            "Type": "EnsurePath",
            "Params": {
                "Exists": [
                    "[variable('Site.Path')]"
                ]
            }
        },
        "CreateAppPool": {
            "Description": "Creates or updates the app pool.",
            "Type": "AppPool",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Properties": {
                    "ProcessModel": {
                        "identityType": "ApplicationPoolIdentity"
                    }
                }
            }
        },
        "CreateWebsite": {
            "Description": "Creates or updates the IIS website instance.",
            "Type": "Website",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "ApplicationPool": "[parameter('SiteName')]",
                "PhysicalPath": "[variable('Site.Path')]"
            }
        },
        "StopWebsite": {
            "Description": "Stops the website if it is running.",
            "Type": "ManageWebsite",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Stop"
            }
        },
        "StopAppPool": {
            "Description": "Stops the app pool if it is running.",
            "Type": "ManageAppPool",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Stop"
            }
        },
        "RemoveDefaultBinding": {
            "Description": "Removes the default *:80 web binding.",
            "Type": "WebBinding",
            "Params": {
                "SiteName": "[parameter('SiteName')]",
                "Remove": [
                    {
                        "Port": "80",
                        "IPAddress": "*"
                    }
                ]
            }
        },
        "CreateBindingsWithThumbprint": {
            "Description": "Configures the site bindings for the website.",
            "Type": "WebBinding",
            "Params": {
                "SiteName": "[parameter('SiteName')]",
                "Add": [
                    {
                        "HostHeader": "[parameter('DnsName')]",
                        "Protocol": "https",
                        "SSLFlags": 1,
                        "Thumbprint": "[variable('Certificates.Site.Thumbprint')]"
                    }
                ]
            },
            "Skip": "[not(parameter('SSLCert'))]"
        },
        "CreateHostHeader": {
            "Description": "Sets a hostheader for the website.",
            "Type": "HostHeader",
            "Params": {
                "HostName": "[parameter('HostMappingName')]"
            },
            "Skip": "[not(parameter('HostMappingName'))]"
        },
        "SetPermissions": {
            "Description": "Sets permissions for the app pool user.",
            "Type": "FilePermissions",
            "Params": {
                "Path": "[variable('Site.Path')]",
                "Rights": [
                    {
                        "User": "[concat('IIS AppPool\\', parameter('SiteName'))]",
                        "FileSystemRights": "FullControl",
                        "InheritanceFlags": [
                            "ContainerInherit",
                            "ObjectInherit"
                        ]
                    }
                ]
            }
        },
        "InstallWDP": {
            "Type": "WebDeploy",
            "Params": {
                "Verb": "Sync",
                "Arguments": {
                    "Source": {
                        "Package": "[resolvepath(variable('Package'))]"
                    },
                    "Dest": "Auto",
                    "SetParam": [
                        {
                            "Name": "Application Path",
                            "Value": "[parameter('SiteName')]"
                        },
                        {
                            "Name": "Database Server Name",
                            "Value": "[parameter('SqlServer')]"
                        },
                        {
                            "Name": "Core DB Name",
                            "Value": "[variable('Sql.Database.Core.Name')]"
                        },
                        {
                            "Name": "Security DB Name",
                            "Value": "[variable('Sql.Database.Security.Name')]"
                        },
                        {
                            "Name": "Master DB Name",
                            "Value": "[variable('Sql.Database.Master.Name')]"
                        },
                        {
                            "Name": "Reporting DB Name",
                            "Value": "[variable('Sql.Database.Reporting.Name')]"
                        },
                        {
                            "Name": "Core DB User Name",
                            "Value": "[parameter('SqlCoreUser')]"
                        },
                        {
                            "Name": "Core DB User Password",
                            "Value": "[variable('Sql.Database.Core.Password')]"
                        },
                        {
                            "Name": "Security DB User Name",
                            "Value": "[parameter('SqlSecurityUser')]"
                        },
                        {
                            "Name": "Security DB User Password",
                            "Value": "[variable('Sql.Database.Security.Password')]"
                        },
                        {
                            "Name": "Master DB User Name",
                            "Value": "[parameter('SqlMasterUser')]"
                        },
                        {
                            "Name": "Master DB User Password",
                            "Value": "[variable('Sql.Database.Master.Password')]"
                        },
                        {
                            "Name": "Reporting DB User Name",
                            "Value": "[parameter('SqlReportingUser')]"
                        },
                        {
                            "Name": "Reporting DB User Password",
                            "Value": "[variable('Sql.Database.Reporting.Password')]"
                        },
                        {
                            "Name": "Reporting Service Api Key",
                            "Value": "[variable('ReportingService.ApiKey')]"
                        }
                    ]
                }
            }
        },
        "CreateBindingsWithDevelopmentThumbprint": {
            "Description": "Creates a new thumbprint with a custom CA.",
            "Type": "AddWebFeatureSSL",
            "Params": {
                "SiteName": "[parameter('SiteName')]",
                "HostName": "[parameter('DnsName')]",
                "OutputDirectory": "[variable('Site.DataFolder')]"
            },
            "Skip": "[parameter('SSLCert')]"
        },
        "SetLicense": {
            "Description": "Copies the license file to the instance data folder.",
            "Type": "Copy",
            "Params": {
                "Source": "[resolvepath(parameter('LicenseFile'))]",
                "Destination": "[variable('Site.DataFolder')]"
            }
        },
        "StartAppPool": {
            "Description": "Starts the app pool.",
            "Type": "ManageAppPool",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Start"
            }
        },
        "StartWebsite": {
            "Description": "Starts the website.",
            "Type": "ManageWebsite",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Start"
            }
        }
    },
    "UninstallTasks": {
        "StopWebsite": {
            "Description": "Stops the website if it is running.",
            "Type": "ManageWebsite",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Stop",
                "ErrorAction": "SilentlyContinue"
            }
        },
        "StopAppPool": {
            "Description": "Stops the app pool if it is running.",
            "Type": "ManageAppPool",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Stop",
                "ErrorAction": "SilentlyContinue"
            }
        },
        "RemoveWebsite": {
            "Description": "Removes the IIS website.",
            "Type": "RemoveWebsite",
            "Params": {
                "Name": "[parameter('SiteName')]"
            }
        },
        "RemoveAppPool": {
            "Description": "Removes the IIS application pool.",
            "Type": "RemoveAppPool",
            "Params": {
                "Name": "[parameter('SiteName')]"
            }
        },
        "RemoveContent": {
            "Description": "Removes website content.",
            "Type": "RemoveItem",
            "Params": {
                "Path": "[variable('Site.Path')]",
                "Recurse": true,
                "ErrorAction": "SilentlyContinue"
            }
        },
        "RemoveHostHeader": {
            "Description": "Removes the website host name.",
            "Type": "HostHeader",
            "Params": {
                "HostName": "[parameter('SiteName')]",
                "Action": "Remove"
            }
        }
    }
}