SIF/1001/SXA/sxa-XP0.json

{
    "Parameters": {
        "Package": {
            "Type": "string",
            "Description": "The path to the Web Deploy package to deploy.",
            "DefaultValue": ""
        },
        "SqlDbPrefix": {
            "Type": "string",
            "Description": "The prefix used for all Sql databases.",
            "DefaultValue": ""
        },
        "SolrCorePrefix": {
            "Type": "string",
            "Description": "The prefix used for all Solr cores.",
            "DefaultValue": ""
        },
        "SiteName": {
            "Type": "string",
            "DefaultValue": "Sitecore",
            "Description": "The name of the site to be deployed."
        },
        "SitecoreAdminPassword": {
            "Type": "string",
            "DefaultValue": "b",
            "Description": "The admin password for the Sitecore instance."
        },
        "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."
        },
        "SqlServer": {
            "Type": "string",
            "DefaultValue": ".\\SQLSERVER",
            "Description": "The Sql Server where databases will be installed."
        },
        "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"
        }
    },
    "Register": {
        "ConfigFunction": {
            "TestPath": "Test-Path",
            "SelectObject": "Select-Object",
            "SplitPath": "Split-Path"
        }
    },
    "Variables": {
        "Sql.Database.Core.Name": "[concat(parameter('SqlDbPrefix'), '_Core')]",
        "Sql.Database.Master.Name": "[concat(parameter('SqlDbPrefix'), '_Master')]",
 
        "Sql.Database.Core.ConnectionString": "[SqlConnectionString(Server:parameter('SqlServer'),Database:variable('Sql.Database.Core.Name'),UserName:parameter('SqlAdminUser'),Password:parameter('SqlAdminPassword'))]",
        "Sql.Database.Master.ConnectionString": "[SqlConnectionString(Server:parameter('SqlServer'),Database:variable('Sql.Database.Master.Name'),UserName:parameter('SqlAdminUser'),Password:parameter('SqlAdminPassword'))]",
 
        "Solr.Core.Master.Name": "[concat(parameter('SolrCorePrefix'), '_sxa_master_index')]",
        "Solr.Core.Web.Name": "[concat(parameter('SolrCorePrefix'), '_sxa_web_index')]",
 
        "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')]",
 
        "Packages.DownloadLocations.File": "[ReadJson(parameter('DownloadLocations'))]",
        "Packages.DownloadLocations.File.Test": "[TestPath(Path:Parameter('DownloadLocations'))]",
 
        "Package.Download.Identifier": "sxa-XP0.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'),'')]"
    },
    "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')]"
        },
        "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"
            }
        },
        "InstallWDP": {
            "Description": "Syncs the web deploy package with the website.",
            "Type": "WebDeploy",
            "Params": {
                "Verb": "Sync",
                "Arguments": {
                    "Source": {
                        "Package": "[resolvepath(variable('Package'))]"
                    },
                    "Dest": "Auto",
                    "enableRule": "DoNotDeleteRule",
                    "SetParam": [
                        {
                            "Name": "Application Path",
                            "Value": "[parameter('SiteName')]"
                        },
                        {
                            "Name": "Core Admin Connection String",
                            "Value": "[variable('Sql.Database.Core.ConnectionString')]"
                        },
                        {
                            "Name": "Master Admin Connection String",
                            "Value": "[variable('Sql.Database.Master.ConnectionString')]"
                        },
                        {
                            "Name": "Solr Master Index Name",
                            "Value": "[variable('Solr.Core.Master.Name')]"
                        },
                        {
                            "Name": "Solr Web Index Name",
                            "Value": "[variable('Solr.Core.Web.Name')]"
                        }
                    ]
                }
            }
        },
        "TransformXmlDocuments": {
            "Type": "TransformXmlDoc",
            "Params": {
                "RootDirectoryPath": "[variable('Site.Path')]",
                "XdtDirectory": "[joinpath(variable('Site.DataFolder'), 'SxaXdt')]"
            }
        },
        "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"
            }
        },
        "UpdateSolrSchema": {
            "Type": "SitecoreUrl",
            "Params": {
                "SitecoreInstanceRoot": "[concat('https://', parameter('SiteName'))]",
                "SitecoreActionPath": "sitecore/admin/PopulateManagedSchema.aspx?indexes=all",
                "UserName": "admin",
                "Password": "[parameter('SitecoreAdminPassword')]"
            }
        },
        "CleanupDatabase": {
            "Type": "SitecoreUrl",
            "Params": {
                "SitecoreInstanceRoot": "[concat('https://', parameter('SiteName'))]",
                "SitecoreActionPath": "sitecore/admin/CleanupDatabase.aspx",
                "UserName": "admin",
                "Password": "[parameter('SitecoreAdminPassword')]"
            }
        }
    }
}