I want to create an App Service Plan (Consumption) through powershell task. For this i used Azure Powershell task, And my code is:
[cmdletbinding()]
param (
$AppServicePlanLocation,
$AppServicePlanResourceGroupName,
$AppServicePlan_Name
)
$location = $AppServicePlanLocation
$resourceGroupName = $AppServicePlanResourceGroupName
$appServicePlanName = $AppServicePlan_Name
Write-Host "SafeCreateAppServicePlan.Parameter:location: $location"
Write-Host "SafeCreateAppServicePlan.Parameter:resourceGroupName: $resourceGroupName"
Write-Host "SafeCreateAppServicePlan.Parameter:appServicePlanName: $appServicePlanName"
$SkuName = "Y1"
$SkuTier = "Dynamic"
$WebAppApiVersion = "2015-08-01"
$fullObject = @{
location = $location
sku = @{
name = $SkuName
tier = $SkuTier
}
}
Write-Host "Ensuring the $appServicePlanName app service plan exists"
$plan = Get-AzureRmAppServicePlan -Name $appServicePlanName -ResourceGroupName $resourceGroupName -ErrorAction SilentlyContinue
if(-not $plan) {
Write-Host "Creating $appServicePlanName app service plan"
New-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/serverfarms -Name $appServicePlanName -IsFullObject -PropertyObject $fullObject -ApiVersion $WebAppApiVersion -Force
}
else {
Write-Host "$appServicePlanName app service plan already exists"
}
But it is giving error: The term 'Get-AzureRmAppServicePlan' 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.
Azure Powershell task is not recognizing Get-AzureRmAppServicePlan command.
Note: I have not used simple powershell task, I have used Azure Powershell task.