Disable azure function app remote debugging using Az Powershell - azure

Does anyone know how i can disable remote debugging using Az Powershell?
I know we can do that using az cli, which looks something like this
az functionapp config set \
--name Appname \
--ftps-state "Disabled" \
--subscription mysubscription \
--remote-debugging-enabled false \
--resource-group myresourcegroup
Any help would be great.
Thanks

Try the command below, it works fine on my side.
$Resource = Get-AzResource -ResourceGroupName <Resource Group Name> -ResourceType Microsoft.Web/sites/config -ResourceName "<Function App Name>" -ApiVersion "2018-02-01"
$Resource.Properties.remoteDebuggingEnabled = "False"
$Resource | Set-AzResource -ApiVersion "2018-02-01" -Force

Related

OS Type Conflict running Azure CLI command from PowerShell

I am running an Azure CLI command in a Windows 10 Professional PowerShell script and I receive this error:
(Conflict) Run command OS type 'Windows' does not match the target OS Linux.
PowerShell version:
Major Minor Build Revision
----- ----- ----- --------
5 1 19041 1237
The failing PowerShell script:
$ResourceGroup= "Development"
$VmName = "ubuntu-test"
az vm run-command invoke `
--resource-group $ResourceGroup `
--name $VmName `
--command-id RunPowerShellScript `
--scripts "ufw disable"
Note: The ` character is the backtick. The one on the same key as the tilde ~
The same command without line continuation backticks works:
az vm run-command invoke --resource-group Development --name ubuntu-test --command-id RunShellScript --scripts "ufw disable"
If I do a Write-Host the output is a single line with the correct arguments minus the quotes around the --script command.
Write-Host az vm run-command invoke `
--resource-group $ResourceGroup `
--name $VmName `
--command-id RunPowerShellScript `
--scripts "ufw disable"
az vm run-command invoke --resource-group Development --name ubuntu-test --command-id RunPowerShellScript --scripts ufw disable
The documentation for the AZ CLI invoke command mentions nothing about setting the OS Type.
az VM run-command invoke
I think the use of line-continuations (` at the very end of lines) is incidental to your problem.
Apart from the use of variables vs. literals, the crucial difference between your multi-line command and your working single-line command is:
--command-id RunPowerShellScript vs. --command-id RunShellScript.
It looks like the VM you're targeting is a Linux machine, and that --command-id RunPowerShellScript isn't supported there, whereas --command-id RunShellScript is.
az vm run-command list ... can apparently be used to discover supported --command-id values.

Is there a powershell command to add ipRules to CosmosDB in azure?

I'm trying to add an ip to the network rules of CosmosDb (firewall) in azure, using powershell.
A lot of other resources seem to have a command available to do this (eg. keyvault Add-AzKeyVaultNetworkRule -VaultName myvault -IpAddressRange "10.0.1.0/24"), but I can't find any for CosmosDb. Does anyone know if it actually exist? Thanks!
Yes, Update-AzCosmosDBAccount
$resourceGroupName = "myResourceGroup"
$accountName = "my-cosmos-account"
$ipFilter = #("10.0.0.0/8", "11.0.1.0/24")
$allowAzureAccess = $true
if ($true -eq $allowAzureAccess) {
$ipFilter += "0.0.0.0"
}
Update-AzCosmosDBAccount -ResourceGroupName $resourceGroupName `
-Name $accountName -IpRangeFilter $ipFilter

How to mount storage to app service using Az powershell module

I am running the following command
az webapp config storage-account add -g appxxx-dfpg-dev2-web-eastus2 --name appxxx-dfpg-dev2-web-eastus2-backoffice-apsvc --storage-type AzureBlob --share-name central-imports-dev4 --access-key XXXXXXXXXXXXXXXXXXX== -a appxxxdfpgg --mount-path /central-imports -i CentralImports
And it works fine.
How I can achieve the same result using Az powershell module, I guess I need to use Az.Websites module.
What you are looking for is New-AzWebAppAzureStoragePath command, use it to create an Azure Storage path, then use Set-AzWebApp to update the web app.
Sample:
$storagePath1 = New-AzWebAppAzureStoragePath -Name "RemoteStorageAccount1" -AccountName "myaccount.files.core.windows.net" -Type AzureFiles -ShareName "someShareName" -AccessKey "some access key"
-MountPath "C:\myFolderInsideTheContainerWebApp"
$storagePath2 = New-AzWebAppAzureStoragePath -Name "RemoteStorageAccount2" -AccountName "myaccount2.files.core.windows.net" -Type AzureFiles -ShareName "someShareName2" -AccessKey "some access key 2"
-MountPath "C:\myFolderInsideTheContainerWebApp2"
Set-AzWebApp -ResourceGroup myresourcegroup -Name myapp -AzureStoragePath $storagepath1, $storagePath2

How do I disable Kudu (SCM) for a stopped Azure Web App using PowerShell?

How do I disable Kudu (SCM) for a stopped Azure Web App using the Az.Websites PowerShell module?
I tried this:
$app = Get-AzWebApp -Name $appName
$app.ScmSiteAlsoStopped = $true
Set-AzWebApp -WebApp $app
$app = Get-AzWebApp -Name $appName
$app.ScmSiteAlsoStopped
But it returns False.
You could do that via Az.Resources module, try the command as below.
$app = Get-AzResource -ResourceGroupName <ResourceGroupName> -ResourceType Microsoft.Web/sites -ResourceName "<webapp name>"
$app.properties.ScmSiteAlsoStopped = $true
$app | Set-AzResource -Force

Setting IP Restrictions to all slots in an AppService Web App using powershell

I have a PS script which contains something like this to set IP restrictions on a Web App. This works great, however our PROD Web App has a Staging slot. How can I set the same restrictions in all slots? Unfortunately this is not yet supported by the portal..
# Update IP restrictions if modified
$WebAppConfig.properties.ipSecurityRestrictions = $ArrayList
$WebAppConfig | Set-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $WebApp/web -ApiVersion $APIVersion -Force | Out-Null
Huge thanks!
Try the script as below, my Webapp named joywebapp2, the slot named slot1, the script set the slot with the same IpSecurityRestrictions of the Webapp, if you have several slots, just use a loop.
$IpSecurityRestrictions = (Get-AzureRmWebApp -ResourceGroupName joywebapp -Name joywebapp2).SiteConfig.IpSecurityRestrictions
$slot = Get-AzureRmWebAppSlot -ResourceGroupName joywebapp -Name joywebapp2 -Slot slot1
$slot.SiteConfig.ipSecurityRestrictions = $IpSecurityRestrictions
$slot | Set-AzureRmWebAppSlot
Update:
If you want to use Az module, the command should be like as below.
$IpSecurityRestrictions = (Get-AzWebApp -ResourceGroupName joywebapp -Name joywebapp2).SiteConfig.IpSecurityRestrictions
$slot = Get-AzWebAppSlot -ResourceGroupName joywebapp -Name joywebapp2 -Slot slot1
$slot.SiteConfig.ipSecurityRestrictions = $IpSecurityRestrictions
$slot | Set-AzWebAppSlot

Resources