PowerShell Command for Azure App Service Deployment Returns 403 Forbidden Error

Srishti Purohit 10 Reputation points Microsoft Employee
2025-06-17T00:57:48.8433333+00:00

The following PowerShell command used for deploying an App Service is returning a runtime error that wasn't occurring before:

Invoke-RestMethod -Uri $kuduApiUrl -Headers @{Authorization = ("Bearer {0}" -f $accessToken)} -Method POST -InFile $ZipPackageFile -ContentType "multipart/form-data"

The error logs indicate a 403 Forbidden response:

##[debug]
##[debug]Script stack trace:
##[debug]at Invoke-ZipDeploy, D:\a\_work\1\ps\Publish-AzureWebApp.ps1: line 101
##[debug]at <ScriptBlock>, D:\a\_work\1\ps\Publish-AzureWebApp.ps1: line 163
##[debug]at <ScriptBlock>, D:\a\_work\_temp\9c96cb1f-d880-449c-9bec-3f6559156ed8.ps1: line 39
##[debug]at <ScriptBlock>, <No file>: line 1
##[debug]Exception:
##[debug]Microsoft.PowerShell.Commands.HttpResponseException: Response status code does not indicate success: 403 (Forbidden).
##[debug] at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)

What permissions might have changed that could be causing this issue? PFA the PS file which is getting used in CD pipeline.

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.


1 answer

Sort by: Newest
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    11 deleted comments

    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.