Pipelines/Steps/Install/OnPrem/Sitecore/XP/Scaled/9.2/0/sitecore-XP1-prc.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"
        },
        "XConnectCert": {
            "Type": "string",
            "Description": "The certificate to use for encryption. Provide the name or the thumbprint.",
            "DefaultValue": ""
        },
        "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": "SitecoreProcessing",
            "Description": "The name of the site to be deployed."
        },
        "SqlAdminUser": {
            "Type": "string",
            "DefaultValue": "sa",
            "Description": "The Sql admin user account to use when installing databases."
        },
        "SqlAdminPassword": {
            "Type": "string",
            "DefaultValue": "12345",
            "Description": "The Sql admin password to use when installing databases."
        },
        "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."
        },
        "SqlReferenceDataUser": {
            "Type": "string",
            "DefaultValue": "referencedatauser",
            "Description": "The Sql user for the Reference Data connection string in Sitecore."
        },
        "SqlReferenceDataPassword": {
            "Type": "string",
            "DefaultValue": "SIF-Default",
            "Description": "The Sql password for the Reference Data connection string in Sitecore."
        },
        "SqlProcessingPoolsUser": {
            "Type": "string",
            "DefaultValue": "poolsuser",
            "Description": "The user to create and use in Processing Pools connection string."
        },
        "SqlProcessingPoolsPassword": {
            "Type": "string",
            "DefaultValue": "SIF-Default",
            "Description": "The Sql password for the Processing Pools connection string in Sitecore."
        },
        "SqlProcessingTasksUser": {
            "Type": "string",
            "DefaultValue": "tasksuser",
            "Description": "The user to create and use in Processing Tasks connection string."
        },
        "SqlProcessingTasksPassword": {
            "Type": "string",
            "DefaultValue": "SIF-Default",
            "Description": "The Sql password for the Processing Tasks connection string in Sitecore."
        },
        "SqlServer": {
            "Type": "string",
            "DefaultValue": ".\\SQLSERVER",
            "Description": "The Sql Server where databases will be installed."
        },
        "XConnectCollectionService": {
            "Type": "string",
            "DefaultValue": "https://XConnectCollection",
            "Description": "The url for the XConnect Collection Service."
        },
        "ReportingServiceApiKey": {
            "Type": "string",
            "DefaultValue": "SIF-Default",
            "Description": "The api key to use with the Reporting Service server. abcde111112222233333444445555566"
        },
        "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."
        }
    },
    "Variables": {
        "Sql.Database.Core": "[concat(parameter('SqlDbPrefix'), '_Core')]",
        "Sql.Database.Security":"[concat(parameter('SqlDbPrefix'), '_Core')]",
        "Sql.Database.Master": "[concat(parameter('SqlDbPrefix'), '_Master')]",
        "Sql.Database.Web": "[concat(parameter('SqlDbPrefix'), '_Web')]",
        "Sql.Database.Reporting": "[concat(parameter('SqlDbPrefix'), '_Reporting')]",
        "Sql.Database.Reference": "[concat(parameter('SqlDbPrefix'), '_ReferenceData')]",
        "Sql.Database.Pools": "[concat(parameter('SqlDbPrefix'), '_Processing.Pools')]",
        "Sql.Database.Tasks": "[concat(parameter('SqlDbPrefix'), '_Processing.Tasks')]",
 
        "SqlProcessingTasks.Password": "[parameter('SqlProcessingTasksPassword'))]",
 
        "SqlReferenceData.Password": "[parameter('SqlReferenceDataPassword')]",
        "SqlReporting.Password":"[parameter('SqlReportingPassword')]",
        "SqlCore.Password": "[parameter('SqlCorePassword')]",
        "SqlSecurity.Password": "[parameter('SqlSecurityPassword')]",
        "SqlMaster.Password": "[parameter('SqlMasterPassword')]",
        "SqlProcessingPools.Password": "[parameter('SqlProcessingPoolsPassword')]",
 
        "ReportingService.ApiKey": "[parameter('ReportingServiceApiKey')]",
 
        "Security.CertificateStore": "Cert:\\Localmachine\\My",
        "Security.SSL.CertificateThumbprint": "[GetCertificateThumbprint(parameter('SSLCert'), variable('Security.CertificateStore'))]",
        "Security.XConnect.CertificateThumbprint": "[GetCertificateThumbprint(parameter('XConnectCert'), variable('Security.CertificateStore'))]",
        "Security.XConnect.CertificatePath": "[joinpath(variable('Security.CertificateStore'), variable('Security.XConnect.CertificateThumbprint'))]",
 
        "Site.PhysicalPath": "[joinpath(environment('SystemDrive'), 'inetpub', 'wwwroot', parameter('SiteName'))]",
        "Site.DataFolder": "[joinpath(variable('Site.PhysicalPath'), 'App_Data')]",
 
        "Sql.Secure.Password" : "[ConvertToSecureString(String:parameter('SqlAdminPassword'),AsPlainText:true,Force:true)]"
    },
    "Register":{
        "Tasks": {
            "RemoveItem": "Remove-Item"
        },
        "ConfigFunction": {
            "ConvertToSecureString": "ConvertTo-SecureString"
        }
    },
    "Tasks": {
        "CreatePaths": {
            "Description": "Ensure the destination path for the site exists.",
            "Type": "EnsurePath",
            "Params": {
                "Exists": [ "[variable('Site.PhysicalPath')]" ]
            }
        },
        "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.PhysicalPath')]"
            }
        },
        "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('Security.SSL.CertificateThumbprint')]"
                    }
                ]
            },
            "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.PhysicalPath')]",
                "Rights": [
                    {
                        "User": "[concat('IIS AppPool\\', parameter('SiteName'))]",
                        "FileSystemRights": "FullControl",
                        "InheritanceFlags": [ "ContainerInherit", "ObjectInherit"]
                    }
                ]
            }
        },
        "SetCertStorePermissions": {
            "Description": "Set permissions for the services to access the client certificate.",
            "Type": "FilePermissions",
            "Params": {
                "Path" : "[ResolveCertificatePath(variable('Security.XConnect.CertificatePath'))]",
                "Rights": [
                    {
                        "User": "[concat('IIS AppPool\\', parameter('SiteName'))]",
                        "FileSystemRights": ["Read"],
                        "InheritanceFlags": [ "None"]
                    }
                ]
            }
        },
        "InstallWDP": {
            "Type": "WebDeploy",
            "Params" :{
                "Verb": "Sync",
                "Arguments": {
                    "Source": {
                        "Package": "[resolvepath(parameter('Package'))]"
                    },
                    "Dest": "Auto",
                    "SetParam": [
                        { "Name": "Application Path", "Value": "[parameter('SiteName')]" },
                        { "Name": "Database Server Name", "Value": "[parameter('SqlServer')]" },
                        { "Name": "Database Admin User Name", "Value": "[parameter('SqlAdminUser')]" },
                        { "Name": "Database Admin User Password", "Value": "[parameter('SqlAdminPassword')]" },
                        { "Name": "Core DB Name", "Value": "[variable('Sql.Database.Core')]" },
                        { "Name": "Security DB Name", "Value": "[variable('Sql.Database.Security')]" },
                        { "Name": "Master DB Name", "Value": "[variable('Sql.Database.Master')]" },
                        { "Name": "Reporting DB Name", "Value": "[variable('Sql.Database.Reporting')]" },
                        { "Name": "XDB Reference Data DB Name", "Value": "[variable('Sql.Database.Reference')]" },
                        { "Name": "Processing Pools DB Name", "Value": "[variable('Sql.Database.Pools')]" },
                        { "Name": "Processing Tasks DB Name", "Value": "[variable('Sql.Database.Tasks')]" },
                        { "Name": "Core DB User Name", "Value": "[parameter('SqlCoreUser')]" },
                        { "Name": "Core DB User Password", "Value": "[variable('SqlCore.Password')]" },
                        { "Name": "Security DB User Name", "Value": "[parameter('SqlSecurityUser')]" },
                        { "Name": "Security DB User Password", "Value": "[variable('SqlSecurity.Password')]" },
                        { "Name": "Master DB User Name", "Value": "[parameter('SqlMasterUser')]" },
                        { "Name": "Master DB User Password", "Value": "[variable('SqlMaster.Password')]" },
                        { "Name": "Reporting DB User Name", "Value": "[parameter('SqlReportingUser')]" },
                        { "Name": "Reporting DB User Password", "Value": "[variable('SqlReporting.Password')]" },
                        { "Name": "XDB Reference Data DB User Name", "Value": "[parameter('SqlReferenceDataUser')]" },
                        { "Name": "XDB Reference Data DB User Password", "Value": "[variable('SqlReferenceData.Password')]" },
                        { "Name": "Processing Pools DB User Name", "Value": "[parameter('SqlProcessingPoolsUser')]" },
                        { "Name": "Processing Pools DB User Password", "Value": "[variable('SqlProcessingPools.Password')]" },
                        { "Name": "Processing Tasks DB User Name", "Value": "[parameter('SqlProcessingTasksUser')]" },
                        { "Name": "Processing Tasks DB User Password", "Value": "[variable('SqlProcessingTasks.Password')]" },
                        { "Name": "XConnect Collection", "Value": "[parameter('XConnectCollectionService')]" },
                        { "Name": "XConnect Server Certificate Validation Thumbprint", "Value": "[variable('Security.XConnect.CertificateThumbprint')]" },
                        { "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.PhysicalPath')]",
                "Recurse": true,
                "ErrorAction": "SilentlyContinue"
            }
        },
        "RemoveHostHeader": {
            "Description": "Removes the website host name.",
            "Type": "HostHeader",
            "Params": {
                "HostName": "[parameter('SiteName')]",
                "Action": "Remove"
            }
        },
        "RemoveDatabases": {
            "Description": "Removes the databases.",
            "Type": "RemoveSQLDatabase",
            "Params": {
                "ServerName": "[parameter('SqlServer')]",
                "Username": "[parameter('SqlAdminUser')]",
                "Password": "[variable('Sql.Secure.Password')]",
                "DatabaseName": [
                    "[variable('Sql.Database.Tasks')]"
                ]
            }
        }
    }
}