Unable to set SKU using Set-AzureRmResource - powershell

I am using Azure PowerShell and using Azure Resource Manager commandlets to set SKU to "Standard". The following examples isn't working
$azsite = Get-AzureRmResource -ResourceType "Microsoft.Web/Sites" -ResourceName "azwebapp" -ResourceGroupName "DefaultResourceGroupName"
$azsite.properties.sku = "standard"
$az | set-azurermresource -Force
The resource still has the free tier.
I also tried.
Set-AzureRmResource -ResourceType "Microsoft.Web/Sites" -ResourceName "azwebapp" -ResourceGroupName "DefaultResourceGroupName" -Sku #{"name" = "standard"} -Force
And still it doesn't change the resource sku to standard.

The best thing is to use the dedicated app service plan cmdlets more over the sku is an app service plan property, you can use the following example
Set-AzureRmAppServicePlan -ResourceGroupName DefaultResourceGroupName -Name <AppServicePlanName> -Tier Standard

Related

Remove-AzureRmResourceGroupDeployment not removing the azure dev test lab

I created a dev test lab from powershell using the command :
New-AzureRmResourceGroupDeployment -Name MyLab -ResourceGroupName MyLabRG -TemplateUri https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/101-dtl-create-lab/azuredeploy.json
Now after I am done doing some operations in the lab, I want to delete it. So I use
Remove-AzureRmResourceGroupDeployment -Name MyLab -ResourceGroupName MyLabRG
It returns True, but when I check the Dev Test lab in portal, it is still there. Am I missing something?
If you want to remove the dev test lab, please have a try to use the following command, it works correctly on my side.
Remove-AzureRmResource -ResourceGroupName $resourcegroupName -ResourceType Microsoft.DevTestLab/labs -ResourceName $resourceName -ApiVersion 2016-05-15 -Force

List instances of Azure App Service with Powershell RM

My aim is to find all the instance Ids of a particular App Service in Azure so I can write a warm-up routine and test it against all running instances (ARRAfinity).
I can do the following with ASM Powershell but I need it in ARM (RM) as Octopus is configured for it.
(Get-AzureWebsite -Name "site-name" -Slot "Production").Instances
I have found the documentation around RM sparing, and the following hasn't led me to anything helpful:
Get-AzureRmWebApp -Name "site-name"
Any help would be really helpful.
Try something like this:
Get-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/instances -Name $WebAppName -ApiVersion 2016-03-01
See also here for a helper function that also works on slots.
Or you can use:
Get-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName
Resource cmdlets should run faster than Get-AzResource (Get-AzureRmResource), specially with heavy scripts.

How To Configure TLS Mutual Authentication for Azure Web App through PowerShell?

According to the docs you can set ClientCertEnabled through the ARMClient Tool. You can nowadays also use https://resources.azure.com to do so or even set it as property in ARM Templates.
Is there any possibility to set it directly through Azure PowerShell? I found that retrieving an app through Get-AzureRmWebApp also states if ClientCertificates are enabled or not.
Yes, you can set it on the underlying resource. Sample:
$Resource = Get-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites -ResourceName $resourceName -ApiVersion 2016-08-01
$Resource.Properties.clientCertEnabled = "True"
$Resource | Set-AzureRmResource -Force
HTH

Update Azure Website instance size (Small, Medium, Large) with Powershell

Is there a way to scale an Azure WebSite instance size (not instance count) using PowerShell? I haven't found the way.
I know it can be done using Azure CLI or from the Portal, but I want to be able to do it with PowerShell. Is this posible?
I want to update an existing WebSite instance size, not create a new website.
Yes, you first need to know the name of the Resource Group and Web Hosting Plan to which your website belongs, which you can get from the new Azure Portal. Then you can change the worker size to 0 (Small), 1 (Medium) or 2 (Large).
Switch-AzureMode AzureResourceManager
$resourceGroup = "MyResourceGroup"
$webHostingPlan = "MyWebHostingPlan"
$whp = Get-AzureResource `
-Name $webHostingPlan `
-ResourceGroupName $resourceGroup `
-ResourceType "Microsoft.Web/serverFarms" `
-ApiVersion 2014-04-01
$newWorkerSize = 1
$whp.Properties.workerSize = $newWorkerSize
$whp.Properties.workerSizeId = $newWorkerSize
Set-AzureResource `
-Name $webHostingPlan `
-ResourceGroupName $resourceGroup `
-ResourceType "Microsoft.Web/serverFarms" `
-ApiVersion 2014-04-01 `
-PropertyObject $whp.Properties

How to script scaling a Website from Small to Large? [duplicate]

Is there a way to scale an Azure WebSite instance size (not instance count) using PowerShell? I haven't found the way.
I know it can be done using Azure CLI or from the Portal, but I want to be able to do it with PowerShell. Is this posible?
I want to update an existing WebSite instance size, not create a new website.
Yes, you first need to know the name of the Resource Group and Web Hosting Plan to which your website belongs, which you can get from the new Azure Portal. Then you can change the worker size to 0 (Small), 1 (Medium) or 2 (Large).
Switch-AzureMode AzureResourceManager
$resourceGroup = "MyResourceGroup"
$webHostingPlan = "MyWebHostingPlan"
$whp = Get-AzureResource `
-Name $webHostingPlan `
-ResourceGroupName $resourceGroup `
-ResourceType "Microsoft.Web/serverFarms" `
-ApiVersion 2014-04-01
$newWorkerSize = 1
$whp.Properties.workerSize = $newWorkerSize
$whp.Properties.workerSizeId = $newWorkerSize
Set-AzureResource `
-Name $webHostingPlan `
-ResourceGroupName $resourceGroup `
-ResourceType "Microsoft.Web/serverFarms" `
-ApiVersion 2014-04-01 `
-PropertyObject $whp.Properties