Azure / azure-functions-vs-build-sdk

MSBuild task for Azure Functions
MIT License
96 stars 62 forks source link

Cannot publish function app #593

Closed phil-allen-msft closed 1 year ago

phil-allen-msft commented 1 year ago

Copied from https://developercommunity.visualstudio.com/t/Cannot-publish-function-app/10163830

When I try to publish a function app through the current publishing profile, I get the error: The attempt to publish the ZIP file through https://myfunctionapp.scm.azurewebsites.net/api/zipdeploy failed with HTTP status code Conflict.

Maybe related:

Azure authentication inside Visual Studio tells me to reauthenticate but it keeps asking me for adding fresh credentials. When we are at it, ideally the Azure authentication feature should provide more means of authentication, such as az cli, browser or device code. I have many tenants to choose from I had to create the publish profile manually. I couldn’t pick the target function app from the screen.

OP has tried recreating the profile via an export publish profile/import publish profile, no difference in behavior. Deployment Logs available on the SCM side are also empty.

cveld commented 1 year ago

Interestingly when publishing the generated zip by Visual Studio from func cli everything runs fine. I would love to see a more verbose logging of Visual Studio's operations. Is Visual Studio really executing the func cli? If so, how can I inspect the precise commandline? It would be great to replay the http conflict error from the commandline as well.

phil-allen-msft commented 1 year ago

Visual Studio is invoking the Functions SDK to do the build and publish via MSBuild, which uses the ZipDeploy task in order to actually push the bits to the function app. src/Microsoft.NET.Sdk.Functions.MSBuild/Tasks/ZipDeployTask.cs and friends. A commandline that should do the same is, if run from the directory that has the csproj file for the function app: dotnet build /p:PublishProfile="Name of pubxml without extension" -c:Release /p:DeployOnBuild=true -p:Password="password to scm site"

cveld commented 1 year ago

Yes with this command I can reproduce the error in Visual Studio.

The attempt to publish the ZIP file through https://myfunc.scm.azurewebsites.net/api/zipdeploy failed with HTTP status code Conflict.

The app service plan is of type Y1, Linux Consumption.

ramya894 commented 1 year ago

@cveld We are investing the above issue and let you know the findings soon.

ramya894 commented 1 year ago

@cveld : can you update us, is this issue still existing.

cveld commented 1 year ago

I have upgraded nuget package microsoft.net.sdk.functions to version 4.1.3, but still the issue persists.

C:\Users\CarlintVeld.nuget\packages\microsoft.net.sdk.functions\4.1.3\build\Microsoft.NET.Sdk.Functions.Publish.ZipDep loy.targets(46,5): error : The attempt to publish the ZIP file through https://connectedq100func.scm.azurewebsites.net/ api/zipdeploy failed with HTTP status code Conflict. [C:\work\git\IOT_Cloud_Solutions\Develop\AzFunc_AppService s\AzFunc_AppApi\AppApi.csproj]

Is there a way to increase logging in order to see the rest api payload? What would be the essential difference compared to func cli which does work?

ghost commented 1 year ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.