Last active
January 14, 2021 07:57
-
-
Save binduchinnasamy/aac787793ddc2454e870f0d0e0e91def to your computer and use it in GitHub Desktop.
Powershell run book to enable or disable azure function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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