Sitecore 10 XM Single deployment using SAT 2.5.0

Pre-requisites:

a. Download and install Azure Storage Explorer (optional, can use portal instead)

b. Valid Azure subscription

c. Azure Storage Account to upload the Sitecore site and Identity server packages

d. Most important: Install Az module locally if using Sitecore Azure Toolkit 2.5.0 (SAT 2.5.0) or install AzureRm module if using SAT version below 2.5.0. Since we will use SAT 2.5.0, should install Az module:


e. Wdp file for the XM Single Topology relevant to Sitecore XP 10

Ensure to unzip and get the scwdp.zip.

f. Download the corresponding (XM Single, in this case) azuredeploy.parameters.json

g. Download Sitecore Azure Toolkit 2.5.0 (SAT) and unzip to a deployment folder like, c:\sitecore\azure

h. Get the raw Github url for Sitecore 10 azuredeploy.json. Note that this url will vary based on your deployment topology.

i. Download Sitecore Identity 5.0.0 Installation Package

Actual Steps:

1. Create an Azure Blob Storage Account with allow blob public access enabled in Advanced tab  -

2. Open Azure Storage Explorer. login using the Azure subscription and create a Blob Container:

3. Upload the wdp file (Pre-requisite - e) to the Blob Container:

4. Create SAS URI for above WDP:

5. The URI generated from the above step will go into the variable singleMsDeployPackageUrl within azuredeploy.parameters.json (understandably, this file must be downloaded and changes should be made in the downloaded version)

6. Upload pre-requisite i (sitecore identity package) to Azure Storage similar to above wdp, generate SAS URI and copy over the uri to the variable siMsDeployPackageUrl in azuredeploy.parameters.json

7. Open Powershell in admin mode and traverse to the location where you unzipped SAT. In my case, it is c:\sitecore\azure. The SAT is unzipped in a folder named SitecoreAzureToolkit within c:\sitecore\azure. 

8. Generate a self-signed certificate (Powershell in administrator mode) -

8.1

$thumbprint = (New-SelfSignedCertificate `
    -Subject "CN=$env:COMPUTERNAME @ Sitecore, Inc." `
    -Type SSLServerAuthentication `
    -FriendlyName "$env:USERNAME Certificate").Thumbprint

8.2 

In case of $certificateFilePath variable path, provide a valid path in your machine where you want the pfx file to be stored:

$certificateFilePath = "c:\windows\system32\$thumbprint.pfx"
Export-PfxCertificate `
    -cert cert:\LocalMachine\MY\$thumbprint `
    -FilePath "$certificateFilePath" `
    -Password (Read-Host -Prompt "Enter password that would protect the certificate" -AsSecureString)

Note that you will be prompted to provide the password for the certificate, keep note of the password you provide. The certificate password will go into authCertificatePassword parameter in  azuredeploy.parameters.json. Although the screen shot above shows c:\windows\system32, you can understandably generate the cert in your deploy folder. In my case, I created the pfx in c:\windows\system32 and copied over the file to c:\sitecore\azure

9. Apart from licenseXml, authCertificateBlob and deploymentId variables, all others must be filled in azuredeploy.parameters.json. Here is how my filled azuredeploy.parameters.json looks like:

https://raw.githubusercontent.com/navancommits/sitecore10/master/azuredeploy.parameters.json

10. With respect to deployment script, the Sitecore documentation is not updated for SAT 2.5.0 so, the highlighted commands (below) are irrelevant when using the SAT 2.5.0 since Az commands (installed as part of pre-requisite d) will be used instead:


11. Here are the equivalent Az  PS Commands related to deployment:  https://raw.githubusercontent.com/navancommits/sitecore10/master/xm0%20dep%20ps%20script.ps1

Ensure to add your correct subscription id, license file, certificate path etc.

12. Provide Azure credentials when executing the Connect-AzAccount cmd in the above list. The other option is to create a service principal and run the script in a non-obtrusive method.

13. Finally, here is how the final PS cmd window output should look without any (red) errors -

Note that I added the -Verbose param to Start-SitecoreAzureDeployment  cmd to view detailed deployment script messages.

14. Login to Azure portal and pick up the resource group specified in the PS Script and you should see the two app service urls. One should be suffixed with single while the other suffixed with si. Login to Sitecore based on the parameter value provided in azuredeploy.parameters.json

-----

Common Errors:

Error:
Start-SitecoreAzureDeployment : The term 'Set-SCAzureDeployParameters' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
+ Start-SitecoreAzureDeployment -Name $DeploymentId -Location $Location ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Start-SitecoreAzureDeployment

Remove-Item : Cannot find path 'C:\sitecore\azure\temp_fhulgvdq.drd' because it does not exist.
At C:\sitecore\azure\SitecoreAzureToolkit\tools\Sitecore.Cloud.Cmdlets.psm1:125 char:9
+         Remove-Item $paramJsonFile
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\sitecore\azure\temp_fhulgvdq.drd:String) [Remove-Item], ItemNotFound
   Exception
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand

Solution:
The above error is thrown in powershell while trying to import SAT with this cmdlet:
Import-Module .\sitecoreazuretoolkit\tools\Sitecore.Cloud.Cmdlets.psm1 -Verbose

If you downloaded the Sitecore Azure Toolkit as a .ZIP and unzip it, the individual files will be marked as "blocked" files. if they are all blocked your Powershell script wont work.

Before unzipping, right click the zip file, go to security and select the Unblock button on the .ZIP file, then extract.


The above solution worked for me and the import was successful:


Error:

Start-SitecoreAzureDeployment : The term 'Start-SitecoreAzureDeployment' is not recognized as the name of a cmdlet,

function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the

path is correct and try again.

At line:1 char:1

+ Start-SitecoreAzureDeployment -Name $DeploymentId -Location $Location ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (Start-SitecoreAzureDeployment:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException


Solution:

The above error is thrown when trying to directly start the deployment using Start-SitecoreAzureDeployment in step 11. Solution is to run  Import-Module -Verbose .\sitecoreazuretoolkit\tools\Sitecore.Cloud.Cmdlets.psm1 in the deployment folder, in my case, c:\sitecore\azure and then re-try the cmd list in step 11.


Error:

New-AzResourceGroup : Run Connect-AzAccount to login.

At C:\sitecore\azure\sitecoreazuretoolkit\tools\Sitecore.Cloud.Cmdlets.psm1:105 char:13

+             New-AzResourceGroup -Name $Name -Location $Location -Tag  ...

+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : CloseError: (:) [New-AzResourceGroup], PSInvalidOperationException

    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupCmd

   let


New-AzResourceGroupDeployment : Run Connect-AzAccount to login.

At C:\sitecore\azure\sitecoreazuretoolkit\tools\Sitecore.Cloud.Cmdlets.psm1:115 char:35

+ ... eployment = New-AzResourceGroupDeployment -Name $Name -ResourceGroupN ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : CloseError: (:) [New-AzResourceGroupDeployment], PSInvalidOperationException

    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDep

   loymentCmdlet


Solution:

Run Connect-AzAccount  and login to Azure when prompted


Error:

Start-SitecoreAzureDeployment : Exception calling "Add" with "2" argument(s): "Item has already been added. Key in

dictionary: 'licenseXml'  Key being added: 'licenseXml'"

At line:1 char:1

+ Start-SitecoreAzureDeployment -Name $DeploymentId -Location $Location ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException

    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Start-SitecoreAzureDeployment


Solution:

The error is thrown when executing  Start-SitecoreAzureDeployment in step 11 without setting the required parameters for the cmdlet, so set the required parameters before running this cmdlet: Start-SitecoreAzureDeployment -Name $DeploymentId -Location $Location -ArmTemplateUrl $SCTemplates  -ArmParametersPath $ParamFile  -LicenseXmlPath $LicenseFile  -SetKeyValue $Parameters 


Error:

New-AzResourceGroupDeployment : 6:51:45 PM - The deployment 'resgrp20200813' failed with error(s). Showing 2 out of 2

error(s).

Status Message: The resource operation completed with terminal provisioning state 'Failed'. (Code:

ResourceDeploymentFailure)

 - 'sa' is not a valid login name in this version of SQL Server. (Code:InvalidLoginName)

Status Message: The resource operation completed with terminal provisioning state 'Failed'. (Code:

ResourceDeploymentFailure)

 - At least one resource deployment operation failed. Please list deployment operations for details. Please see

https://aka.ms/DeployOperations for usage details. (Code: DeploymentFailed)

   - {

  "status": "Failed",

  "error": {

    "code": "ResourceDeploymentFailure",

    "message": "The resource operation completed with terminal provisioning state 'Failed'.",

    "details": [

      {

        "code": "InvalidLoginName",

        "message": "'sa' is not a valid login name in this version of SQL Server."

      }

    ]

  }

} (Code:Conflict)

CorrelationId: 3e8227fb-8efe-4c64-af12-230718846f34

At C:\sitecore\azure\sitecoreazuretoolkit\tools\Sitecore.Cloud.Cmdlets.psm1:115 char:35

+ ... eployment = New-AzResourceGroupDeployment -Name $Name -ResourceGroupN ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [New-AzResourceGroupDeployment], Exception

    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDep

   loymentCmdlet


Solution:

This error was thrown in a context not relevant to current scenario. But , generally the Sql server created for sitecore instance in azure paas does not allow creation of sa as userid.


Error:

Connect-AzAccount : The term 'Connect-AzAccount' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try

again.

At line:1 char:1

+ Connect-AzAccount

+ ~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (Connect-AzAccount:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException


Solution:

Ensure Az module is installed (by executing in PS: Install-Module Az -AllowClobber) prior to issuing Connect-AzAccount command.


Error:

New-AzResourceGroupDeployment : 1:31:53 PM - The deployment 'newresgrp20200814' failed with error(s). Showing 1 out of

1 error(s).

Status Message: The resource operation completed with terminal provisioning state 'Failed'. (Code:

ResourceDeploymentFailure)

 - At least one resource deployment operation failed. Please list deployment operations for details. Please see

https://aka.ms/DeployOperations for usage details. (Code: DeploymentFailed)

   - {

  "status": "failed",

  "error": {

    "code": "ResourceDeploymentFailure",

    "message": "The resource operation completed with terminal provisioning state 'failed'.",

    "details": [

      {

        "code": "Failed",

        "message": "Failed to download package.\r\nARM-MSDeploy Deploy Failed: 'System.AggregateException: One or more

errors occurred. ---> System.Net.WebException: The remote server returned an error: (403)

Forbidden.\r\n   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n   at

System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)\r\n   at

System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)\r\n   --- End of inner exception stack trace

---\r\n   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n   at

System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)\r\n   at

System.Threading.Tasks.Task.Wait(TimeSpan timeout)\r\n   at

Microsoft.Web.Deployment.WebApi.AppGalleryPackage.<Download>d__13.MoveNext()\r\n--- End

of stack trace from previous location where exception was thrown ---\r\n   at

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at

System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at

Microsoft.Web.Deployment.WebApi.AppGalleryPackage.<Download>d__11.MoveNext()\r\n--- End

of stack trace from previous location where exception was thrown ---\r\n   at

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at

System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.Web.D

eployment.WebApi.DeploymentController.<DownloadPackageAndSettings>d__26.MoveNext()\r\n---

 End of stack trace from previous location where exception was thrown ---\r\n   at

System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at

System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.Web.D

eployment.WebApi.DeploymentController.<DownloadAndDeployPackage>d__25.MoveNext()\r\n---&a

mp;amp;amp;gt; (Inner Exception #0) System.Net.WebException: The remote server returned an error: (403) Forbidden.\r\n

  at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)\r\n   at

System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)\r\n   at

System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)<---\r\n'\r\nARM-MSDeploy Deploy

Failed: 'Microsoft.Web.Deployment.DeploymentXmlException: The declared parameter 'Application Path' is not

recognized.\r\n\r\n   at Microsoft.Web.Deployment.DeploymentSyncParameterCollection.LoadFromFile(XPathNavigator nav,

String fileName, Boolean ignoreExtraSetParameters)\r\n   at

Microsoft.Web.Deployment.WebApi.AppGalleryPackage.LoadSetParameters(DeploymentObject deploymentObject, IDictionary`2

setParams, String setParamXmlFile)\r\n   at Microsoft.Web.Deployment.WebApi.AppGalleryPackage.Deploy(String

deploymentSite, String siteSlotId, Boolean doNotDelete)\r\n   at Microsoft.Web.Deployment.WebApi.DeploymentController.&

amp;amp;lt;DownloadAndDeployPackage>d__25.MoveNext()'\r\nARM-MSDeploy Deploy Failed:

'Microsoft.Web.Deployment.DeploymentXmlException: The declared parameter 'Application Path' is not recognized.\r\n\r\n

  at Microsoft.Web.Deployment.DeploymentSyncParameterCollection.LoadFromFile(XPathNavigator nav, String fileName,

Boolean ignoreExtraSetParameters)\r\n   at

Microsoft.Web.Deployment.WebApi.AppGalleryPackage.LoadSetParameters(DeploymentObject deploymentObject, IDictionary`2

setParams, String setParamXmlFile)\r\n   at Microsoft.Web.Deployment.WebApi.AppGalleryPackage.Deploy(String

deploymentSite, String siteSlotId, Boolean doNotDelete)\r\n   at Microsoft.Web.Deployment.WebApi.DeploymentController.&

amp;lt;DownloadAndDeployPackage>d__25.MoveNext()'\r\nARM-MSDeploy Deploy Failed:

'Microsoft.Web.Deployment.DeploymentXmlException: The declared parameter 'Application Path' is not recognized.\r\n\r\n

  at Microsoft.Web.Deployment.DeploymentSyncParameterCollection.LoadFromFile(XPathNavigator nav, String fileName,

Boolean ignoreExtraSetParameters)\r\n   at

Microsoft.Web.Deployment.WebApi.AppGalleryPackage.LoadSetParameters(DeploymentObject deploymentObject, IDictionary`2

setParams, String setParamXmlFile)\r\n   at Microsoft.Web.Deployment.WebApi.AppGalleryPackage.Deploy(String

deploymentSite, String siteSlotId, Boolean doNotDelete)\r\n   at

Microsoft.Web.Deployment.WebApi.DeploymentController.<DownloadAndDeployPackage>d__25.MoveNext()'"

      }

    ]

  }

} (Code:Conflict)

CorrelationId: 4c0b0266-4ecf-47fe-bca4-16b23a14cd1e

At C:\sitecore\azure\sitecoreazuretoolkit\tools\Sitecore.Cloud.Cmdlets.psm1:115 char:35

+ ... eployment = New-AzResourceGroupDeployment -Name $Name -ResourceGroupN ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [New-AzResourceGroupDeployment], Exception

    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDep

   loymentCmdlet


Solution:
MSDeploy is unable to deploy the package. Be sure to check the blob url for the package. Ensure it is a SAS-generated url and is correct. In my case, I had uploaded the package zip  (generated and added it's sas url) instead of the scwdp.zip (yes, the sas url) while msdeploy needed the scwdp.zip as input. 


References: 

https://doc.sitecore.com/developers/93/sitecore-experience-manager/en/walkthrough--deploying-a-new-sitecore-environment-to-the-microsoft-azure-app-service.html

https://sitecore.stackexchange.com/questions/3300/new-scwebdeploypackage-is-not-recognized/3344

https://www.koenheye.be/getting-started-with-powershell-sitecore-azure-toolkit-part-3/

https://doc.sitecore.com/developers/93/sitecore-experience-manager/en/the-client-certificate-for-sitecore-deployments.html



Comments

Popular Posts