Skip to content

Instantly share code, notes, and snippets.

@binduchinnasamy
Last active January 14, 2021 07:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binduchinnasamy/aac787793ddc2454e870f0d0e0e91def to your computer and use it in GitHub Desktop.
Save binduchinnasamy/aac787793ddc2454e870f0d0e0e91def to your computer and use it in GitHub Desktop.
Powershell run book to enable or disable azure function
$connectionName = "AzureRunAsConnection"
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
Add-AzureRmAccount -ServicePrincipal -TenantId $servicePrincipalConnection.TenantId -ApplicationId $servicePrincipalConnection.ApplicationId -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
$functionname="<<FunctionAppName>>"
$resourceGroupName ="<<Resource Group Name>>"
$webApp = Get-AzureRmWebApp -ResourceGroupName $resourceGroupName -Name $functionname
$appSettingList =$webApp.SiteConfig.AppSettings
$appSettings = @{}
ForEach ($kvp in $appSettingList) {
$appSettings[$kvp.Name] = $kvp.Value
}
$appSettings["AzureWebJobs.<<Function App Name>>.Disabled"] = "true"
$res = Set-AzureRmWebApp -AppSettings $appSettings -ResourceGroupName $resourceGroupName -Name $functionname
Write-Output "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment