I am trying to update My Azure App Service Settings through PowerShell Script and execute the Powershell Script From ADF using an Azure Function Activity. But My Azure Function is failing with below Error. Please Find below my code to update the AAP settings using powershell script.
-------------------------------------------Code.ps1---------------------------------------------------
$webapp=Get-AzWebApp -ResourceGroupName 'MyResourcegroup' -Name 'MyAzureApp'
$appSettings=$webapp.SiteConfig.AppSettings
$newAppSettings = @{}
ForEach ($item in $appSettings) { $newAppSettings[$item.Name] = $item.Value }
$newAppSettings['DatabaseIURL'] = "@Microsoft.keyVault(SecretUri=https://azkeyvault.vault.azure.net/secrets/DatabaseIURL-datasource2Url/b3ea7ec3e03d415b8525da9c99d3fdc1"
Set-AzWebApp -ResourceGroupName 'cms-catalyst-dev-bcnl-rg' -Name 'cms-cloud-dev-bcnl' -AppSettings $newAppSettings
-----------------------------------------ERROR------------------------------------------------------------------------------------
2021-10-28T10:59:50.603 [Error] ERROR: No subscription found in the context. Please ensure that the credentials you provided are authorized to access an Azure subscription, then run Connect-AzAccount to login.Exception :Type : Microsoft.Azure.Commands.Common.Exceptions.AzPSApplicationExceptionErrorKind : UserErrorLineNumber : 60ErrorFileName : ClientFactoryTargetSite :Name : CreateArmClientDeclaringType : Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactoryMemberType : MethodModule : Microsoft.Azure.PowerShell.Authentication.dllStackTrace :at Microsoft.Azure.Commands.Common.Authentication.Factories.ClientFactory.CreateArmClientTClientat Microsoft.Azure.Commands.WebApps.Utilities.WebsitesClient..ctor(IAzureContext context)at Microsoft.Azure.Commands.WebApps.Models.WebAppBaseClientCmdLet.get_WebsitesClient()at Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.GetAzureWebAppCmdlet.ExecuteCmdlet()at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__31.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action
1 executor)at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJobTat Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()Message : No subscription found in the context. Please ensure that the credentials you provided are authorized to access an Azure subscription, then run Connect-AzAccount to login.Data : System.Collections.ListDictionaryInternalSource : Microsoft.Azure.PowerShell.AuthenticationHResult : -2146232832CategoryInfo : CloseError: (:) [Get-AzWebApp], AzPSApplicationExceptionFullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.GetAzureWebAppCmdletInvocationInfo :MyCommand : Get-AzWebAppScriptLineNumber : 26OffsetInLine : 9HistoryId : 1ScriptName : C:\home\site\wwwroot\Az_DB_Switch\run.ps1Line : $webapp=Get-AzWebApp -ResourceGroupName "xyz" -Name "xxyyzz"PositionMessage : At C:\home\site\wwwroot\Az_DB_Switch\run.ps1:26 char:9+ $webapp=Get-AzWebApp -ResourceGroupName "xyz" - …+