SIF/1010/SPE/spe.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": ""
        },
        "SiteName": {
            "Type": "string",
            "DefaultValue": "Sitecore",
            "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."
        },
        "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'))]",
 
        "Packages.DownloadLocations.File": "[ReadJson(parameter('DownloadLocations'))]",
        "Packages.DownloadLocations.File.Test": "[TestPath(Path:Parameter('DownloadLocations'))]",
 
        "Package.Download.Identifier": "spe.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')]"
                        }
                    ]
                }
            }
        },
        "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"
            }
        }
    }
}