Pipelines/Steps/Install/OnPrem/Sitecore/XP/Scaled/9.0/0/xconnect-xp1-MarketingAutomation.json

{
    "Parameters": {
        "Package": {
            "Type": "string",
            "Description": "The path to the Web Deploy package to deploy."
        },
        "LicenseFile": {
            "Type": "string",
            "Description": "The path to the Sitecore license file."
        },
        "SiteName": {
            "Type": "string",
            "DefaultValue": "XConnectMarketingAutomation",
            "Description": "The name of the site to be deployed."
        },
        "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": ""
        },
        "XConnectCert": {
            "Type": "string",
            "Description": "The certificate to use for encryption. Provide the name or the thumbprint."
        },
        "SqlDbPrefix": {
            "Type": "string",
            "Description": "The prefix used for all Sql databases."
        },
        "SqlCollectionUser": {
            "Type": "string",
            "DefaultValue": "collectionuser",
            "Description": "The Sql admin user account to use when installing databases."
        },
        "SqlCollectionPassword": {
            "Type": "string",
            "DefaultValue": "Test12345",
            "Description": "The Sql admin password to use when installing databases."
        },
        "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."
        },
        "SqlProcessingPoolsUser": {
            "Type": "string",
            "DefaultValue": "poolsuser",
            "Description": "The Sql user for the Processing Pools connection string in Sitecore."
        },
        "SqlProcessingPoolsPassword": {
            "Type": "string",
            "DefaultValue": "Test12345",
            "Description": "The Sql password for the Processing Pools 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": "Test12345",
            "Description": "The Sql password for the Reference Data connection string in Sitecore."
        },
        "SqlMarketingAutomationUser": {
            "Type": "string",
            "DefaultValue": "marketingautomationuser",
            "Description": "The Sql user for the Marketing Automation connection string in Sitecore."
        },
        "SqlMarketingAutomationPassword": {
            "Type": "string",
            "DefaultValue": "Test12345",
            "Description": "The Sql password for the Marketing Automation connection string in Sitecore."
        },
        "SqlMessagingUser": {
            "Type": "string",
            "DefaultValue": "messaginguser",
            "Description": "The Sql user for the Messaging connection string in Sitecore."
        },
        "SqlMessagingPassword": {
            "Type": "string",
            "DefaultValue": "Test12345",
            "Description": "The Sql password for the Messaging 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."
        },
        "XConnectReferenceDataService": {
            "Type": "string",
            "DefaultValue": "https://XConnectReferenceData",
            "Description": "The url for the XConnect Collection Search Service."
        },
        "XConnectEnvironment": {
            "Type": "string",
            "DefaultValue": "Development",
            "Description": "The configuration environment for this instance."
        },
        "XConnectLogLevel": {
            "Type": "string",
            "DefaultValue": "Information",
            "Description": "The level of log information to output."
        },
        "InstallDirectory": {
            "Type": "string",
            "Description": "Installation directory"
        }
    },
    "Variables": {
        "Sql.Database.ShardMapManager": "[concat(parameter('SqlDbPrefix'), '_Xdb.Collection.ShardMapManager')]",
        "Sql.Database.Marketing": "[concat(parameter('SqlDbPrefix'), '_MarketingAutomation')]",
        "Sql.Database.Messaging": "[concat(parameter('SqlDbPrefix'), '_Messaging')]",
        "Sql.Database.Pools": "[concat(parameter('SqlDbPrefix'), '_Processing.Pools')]",
        "Sql.Database.Reference": "[concat(parameter('SqlDbPrefix'), '_ReferenceData')]",
        "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": "[parameter('InstallDirectory')]",
        "Site.DataFolder": "[joinpath(variable('Site.PhysicalPath'), 'App_Data')]",
        "Services.MarketingAutomationEngine.InstallPath": "[joinpath(variable('Site.DataFolder'), 'jobs','continuous','AutomationEngine')]",
        "Services.MarketingAutomationEngine.Name": "[concat(parameter('SiteName'), '-marketingautomationservice')]",
        "Endpoint.Collection": "[parameter('XConnectCollectionService')]",
        "Endpoint.ReferenceData": "[concat(parameter('XConnectReferenceDataService'), '/refdata')]"
    },
    "Tasks": {
        "CreatePaths": {
            "Type": "EnsurePath",
            "Params": {
                "Exists": [
                    "[variable('Site.PhysicalPath')]"
                ]
            }
        },
        "CreateAppPool": {
            "Type": "AppPool",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Properties": {
                    "ProcessModel": {
                        "identityType": "ApplicationPoolIdentity"
                    }
                }
            }
        },
        "SetAppPoolCertStorePermissions": {
            "Type": "FilePermissions",
            "Params": {
                "Path": "[ResolveCertificatePath(variable('Security.XConnect.CertificatePath'))]",
                "Rights": [
                    {
                        "User": "[concat('IIS AppPool\\', parameter('SiteName'))]",
                        "FileSystemRights": [
                            "Read"
                        ],
                        "InheritanceFlags": [
                            "None"
                        ]
                    }
                ]
            }
        },
        "CreateWebsite": {
            "Type": "Website",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "ApplicationPool": "[parameter('SiteName')]",
                "PhysicalPath": "[variable('Site.PhysicalPath')]"
            }
        },
        "StopWebsite": {
            "Type": "ManageWebsite",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Stop"
            }
        },
        "StopAppPool": {
            "Type": "ManageAppPool",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Stop"
            }
        },
        "StopService": {
            "Type": "ManageService",
            "Params": {
                "Name": "[variable('Services.MarketingAutomationEngine.Name')]",
                "Status": "Stopped",
                "PostDelay": 3000
            }
        },
        "RemoveService": {
            "Type": "RemoveService",
            "Params": {
                "Name": "[variable('Services.MarketingAutomationEngine.Name')]"
            }
        },
        "RemoveDefaultBinding": {
            "Type": "WebBinding",
            "Params": {
                "SiteName": "[parameter('SiteName')]",
                "Remove": [
                    {
                        "Port": "80",
                        "IPAddress": "*"
                    }
                ]
            }
        },
        "CreateBindingsWithThumprint": {
            "Type": "WebBinding",
            "Params": {
                "SiteName": "[parameter('SiteName')]",
                "Add": [
                    {
                        "HostHeader": "[parameter('SiteName')]",
                        "Protocol": "https",
                        "SSLFlags": 1,
                        "Thumbprint": "[variable('Security.SSL.CertificateThumbprint')]"
                    }
                ]
            },
            "Skip": "[not(parameter('SSLCert'))]"
        },
        "SetClientCertificatePermissions": {
            "Type": "WebsiteClientCert",
            "Params": {
                "SiteName": "[parameter('SiteName')]",
                "Setting": "Accept"
            }
        },
        "CreateHostHeader": {
            "Type": "HostHeader",
            "Params": {
                "HostName": "[parameter('SiteName')]"
            }
        },
        "SetPermissions": {
            "Type": "FilePermissions",
            "Params": {
                "Path": "[variable('Site.PhysicalPath')]",
                "Rights": [
                    {
                        "User": "[concat('IIS AppPool\\', parameter('SiteName'))]",
                        "FileSystemRights": "FullControl",
                        "InheritanceFlags": [
                            "ContainerInherit",
                            "ObjectInherit"
                        ]
                    }
                ]
            }
        },
        "InstallWDP": {
            "Type": "WebDeploy",
            "Params": {
                "Verb": "Sync",
                "Arguments": {
                    "Source": {
                        "Package": "[resolvepath(parameter('Package'))]"
                    },
                    "Dest": "Auto",
                    "SetParam": [
                        {
                            "Name": "IIS Web Application Name",
                            "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": "Collection Database Server Name",
                            "Value": "[parameter('SqlServer')]"
                        },
                        {
                            "Name": "Collection Shard Map Manager Database Name",
                            "Value": "[variable('Sql.Database.ShardMapManager')]"
                        },
                        {
                            "Name": "Collection Database Application User Name",
                            "Value": "[parameter('SqlCollectionUser')]"
                        },
                        {
                            "Name": "Collection Database Application User Password",
                            "Value": "[parameter('SqlCollectionPassword')]"
                        },
                        {
                            "Name": "Processing Pools Database Name",
                            "Value": "[variable('Sql.Database.Pools')]"
                        },
                        {
                            "Name": "Processing Pool Database Application User Name",
                            "Value": "[parameter('SqlProcessingPoolsUser')]"
                        },
                        {
                            "Name": "Processing Pool Database Application User Password",
                            "Value": "[parameter('SqlProcessingPoolsPassword')]"
                        },
                        {
                            "Name": "Marketing Automation Database Name",
                            "Value": "[variable('Sql.Database.Marketing')]"
                        },
                        {
                            "Name": "Messaging Database Name",
                            "Value": "[variable('Sql.Database.Messaging')]"
                        },
                        {
                            "Name": "Reference Data Database Name",
                            "Value": "[variable('Sql.Database.Reference')]"
                        },
                        {
                            "Name": "Reference Data Database Application User Name",
                            "Value": "[parameter('SqlReferenceDataUser')]"
                        },
                        {
                            "Name": "Reference Data Database Application User Password",
                            "Value": "[parameter('SqlReferenceDataPassword')]"
                        },
                        {
                            "Name": "Marketing Automation Database Application User Name",
                            "Value": "[parameter('SqlMarketingAutomationUser')]"
                        },
                        {
                            "Name": "Marketing Automation Database Application User Password",
                            "Value": "[parameter('SqlMarketingAutomationPassword')]"
                        },
                        {
                            "Name": "Messaging Database Application User Name",
                            "Value": "[parameter('SqlMessagingUser')]"
                        },
                        {
                            "Name": "Messaging Database Application User Password",
                            "Value": "[parameter('SqlMessagingPassword')]"
                        },
                        {
                            "Name": "XConnect Server Configuration Environment",
                            "Value": "[parameter('XConnectEnvironment')]"
                        },
                        {
                            "Name": "XConnect Server Certificate Validation Thumbprint",
                            "Value": "[variable('Security.XConnect.CertificateThumbprint')]"
                        },
                        {
                            "Name": "XConnect Server Log Level",
                            "Value": "[parameter('XConnectLogLevel')]"
                        },
                        {
                            "Name": "Marketing Automation Engine Xconnect Collection Client Endpoint",
                            "Value": "[variable('Endpoint.Collection')]"
                        },
                        {
                            "Name": "Marketing Automation Engine Xconnect Collection Client Certificate Thumbprint",
                            "Value": "[variable('Security.XConnect.CertificateThumbprint')]"
                        },
                        {
                            "Name": "Marketing Automation Engine Xdb Reference Data Endpoint",
                            "Value": "[variable('Endpoint.ReferenceData')]"
                        },
                        {
                            "Name": "Marketing Automation Engine Xdb Reference Data Client Certificate Thumbprint",
                            "Value": "[variable('Security.XConnect.CertificateThumbprint')]"
                        }
                    ]
                }
            }
        },
        "SetLicense": {
            "Type": "Copy",
            "Params": {
                "Source": "[resolvepath(parameter('LicenseFile'))]",
                "Destination": "[variable('Site.DataFolder')]"
            }
        },
        "CreateBindingsWithDevelopmentThumprint": {
            "Type": "AddWebFeatureSSL",
            "Params": {
                "HostName": "[parameter('SiteName')]",
                "OutputDirectory": "[variable('Site.DataFolder')]"
            },
            "Skip": "[parameter('SSLCert')]"
        },
        "StartAppPool": {
            "Type": "ManageAppPool",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Start"
            }
        },
        "StartWebsite": {
            "Type": "ManageWebsite",
            "Params": {
                "Name": "[parameter('SiteName')]",
                "Action": "Start"
            }
        },
        "SetServicesCertStorePermissions": {
            "Type": "FilePermissions",
            "Params": {
                "Path": "[ResolveCertificatePath(variable('Security.XConnect.CertificatePath'))]",
                "Rights": [
                    {
                        "User": "NT AUTHORITY\\LocalService",
                        "FileSystemRights": [
                            "Read"
                        ],
                        "InheritanceFlags": [
                            "None"
                        ]
                    }
                ]
            }
        },
        "CreateServiceLogPath": {
            "Type": "EnsurePath",
            "Params": {
                "Exists": [
                    "[joinpath(variable('Services.MarketingAutomationEngine.InstallPath'), 'App_Data', 'Logs')]"
                ]
            }
        },
        "SetMarketingAutomationServiceLicense": {
            "Type": "Copy",
            "Params": {
                "Source": "[resolvepath(parameter('LicenseFile'))]",
                "Destination": "[joinpath(variable('Services.MarketingAutomationEngine.InstallPath'), 'App_Data')]"
            }
        },
        "SetServicePermissions": {
            "Type": "FilePermissions",
            "Params": {
                "Path": "[joinpath(variable('Services.MarketingAutomationEngine.InstallPath'), 'App_Data', 'Logs')]",
                "Rights": [
                    {
                        "User": "NT AUTHORITY\\LocalService",
                        "FileSystemRights": [
                            "FullControl"
                        ],
                        "InheritanceFlags": [
                            "ContainerInherit",
                            "ObjectInherit"
                        ]
                    }
                ]
            }
        },
        "InstallService": {
            "Type": "Command",
            "Params": {
                "Path": "[joinpath(variable('Services.MarketingAutomationEngine.InstallPath'), 'maengine.exe')]",
                "Arguments": [
                    "-i",
                    "[variable('Services.MarketingAutomationEngine.Name')]"
                ]
            }
        },
        "StartService": {
            "Type": "ManageService",
            "Params": {
                "Name": "[variable('Services.MarketingAutomationEngine.Name')]",
                "Status": "Running"
            }
        }
    }
}