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
Related
I am trying to connect to azure cosmosdb from my local machine via powershell but every command I tried to run it returns the "Argument passed in is not serializable."
Here are a few of my commands,
Get-AzCosmosDBAccount -ResourceGroupName "cosmosbackup"
Invoke-AzCosmosDBSqlDatabaseThroughputMigration -ResourceGroupName "cosmosbackup" -AccountName "liabilitydata" -Name liability
New-AzCosmosDBSqlContainer -AccountName "liabilitydata"-DatabaseName "dailyliability"-ResourceGroupName "cosmosbackup"-Name schemes -PartitionKeyPath /Id -PartitionKeyKind Hash
Get-AzCosmosDBSqlContainer `
-ResourceGroupName "cosmosbackup" `
-AccountName "liabilitydata" `
-DatabaseName "dailyliability"
All of them fail for the same reason Argument passed in is not serializable.
Am I missing something? Please help
The issue here is that you need to set the context for running the script,
Step 1 : Connect with your Azure account
Connect-AzAccount
Step 2 : Pass the resource group and the cosmosdb account name as follows,
Get-AzCosmosDBAccount -ResourceGroupName cosmosbackup
I have been running the following command via powershell for AZURE but all that gets swapped are the application settings:
Switch-AzureRmWebAppSlot -ResourceGroupName 'myresourcegroup' -Name 'mywebsitename' -SourceSlotName "staging" -DestinationSlotName "production" -confirm -verbose
The same thing happens when I run this command:
Switch-AzureRmWebAppSlot -ResourceGroupName 'myresourcegroup' -Name 'mywebsitename' -SourceSlotName "staging" -DestinationSlotName "production" -SwapWithPreviewAction CompleteSlotSwap -confirm -verbose
I cannot use Switch-AzureWebsite as I cannot set a default subscription with my permissions.
Using the Login-AzureRMAccount the only way I found to switch slots is as follows:
$ParametersObject = #{targetSlot = "production"}
$RGN = 'resource-group-name-'
Invoke-AzureRmResourceAction -ResourceGroupName $RGN -ResourceType Microsoft.Web/sites/slots -ResourceName website-name/staging -Action slotsswap -Parameters $ParametersObject -Verbose -force
This was hard to find, in part because many examples required you to set your Azure default subscription prior to executing Switch-AzureWebsite and the other switch only moved the configuration elements over. I am curious if anyone has a clever way to discover power shell commands or ARM template commands aside from the ones generated for deployments on Azure. Ideally, I could perform an action on Azure an then see same thing scripted as PowerShell.
REF: Microsoft Docs Here
I'm automating the deployment of an Azure Web App via powershell. I can't figure out how you force "HTTPS Only" to on. The code below is my best guess, but it isn't working. Any ideas?
$properties = #{"httpsOnly" = $true}
Set-AzureRmResource -PropertyObject $properties -ResourceGroupName
$resourcegroupname -ResourceType Microsoft.Web/sites/config -ResourceName
$webappname/web -ApiVersion 2015-08-01 -Force
You could use the following script.
$app=Get-AzureRmResource -ResourceId "/subscriptions/<subscription id>/resourceGroups/shuiapp/providers/Microsoft.Web/sites/shuicli"
$app.Properties.httpsOnly=$true
$app|Set-AzureRmResource -Force
Note: If you want to set httpsOnly on, the web app's App Service plan must be a paid tier (Shared, Basic, Standard, or Premium). More information about this please check this link.
I also test in Visual Studio, it also works for me.
I suggest you could upgrade your Azure Power Shell version.
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.
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