0

I am trying to deploy vanila sitecore 9.1.1 (XM single) to Azure Paas. For this I am using Sitecore Azure Toolkit and Sitecore ARM templates.

Below is the Powershell script I am using.

$SCTemplates="https://sitecorestorage.blob.core.windows.net/sitecore911/XM"
$DeploymentId = "sitecore911"
$ResourceGroup = "sitecore"
$LicenseFile = "C:\sitecore911\license.xml"
$CertificateFile = "C:\sitecore911\2E803B8D610DBFA92AD99F396426079D3FE406CE.pfx"
$SubscriptionId = "xxxxx"
$Location="East US"
$ParamFile="C:\sitecore911\azuredeploy.parameters.json"
$Parameters = @{
"deploymentId"=$DeploymentId;
"authCertificateBlob" = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($CertificateFile))
}
Import-Module $SCSDK\Sitecore.Cloud.Cmdlets.psm1
Add-AzureRMAccount
Set-AzureRMContext -SubscriptionId $SubscriptionId
Start-SitecoreAzureDeployment -Name $ResourceGroup -Location $Location -ArmTemplateUrl "$SCTemplates/azuredeploy.json" -ArmParametersPath $ParamFile -LicenseXmlPath $LicenseFile -SetKeyValue $Parameters -Verbose

When I execute the above script I get the below error.

WARNING: AzureRM.Profile already loaded. Az and AzureRM modules cannot be imported in the same session or used in the same sc
ript or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to re
move all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks impo
rt both Az and AzureRM modules. More information can be found here: https://aka.ms/azps-migration-guide.
Start-SitecoreAzureDeployment : The 'Get-AzResourceGroup' command was found in the module 'Az.Resources', but the module 
could not be loaded. For more information, run 'Import-Module Az.Resources'.
At C:\sitecore911\DeploySitecore911XM.ps1:16 char:1
+ Start-SitecoreAzureDeployment -Name $ResourceGroup -Location $Locatio ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Start-SitecoreAzureDeployment

I tried uninstalling AzureRm but again I need it to run the below commands.

Add-AzureRMAccount
Set-AzureRMContext -SubscriptionId $SubscriptionId

I am using powershell 5.1 Do we need both AzureRM and AZ ? Do I need to upgrade to powershell 7 ? Any inputs to resolve the issue will be helpfull. Thanks.

1 Answer 1

0

The issue caused by using both AzureRm and Az modules in the same session. So to resolve the issue AzureRm module was removed and script was modified to use only Az commands.

  1. Installed Powershell 7.1.3
  2. Uninstalled AzureRM Module.
Uninstall-AzureRm
  1. Installed the AZ Module.
Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force
  1. Modified the powershell script to use only AZ commands.
Connect-AzAccount -SubscriptionId $SubscriptionId

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.