Azure / functions-action

Enable GitHub developers to deploy to Azure Function Apps using GitHub Actions
MIT License
156 stars 76 forks source link

Dotnet Az Function not working after deployment through Github Action #145

Closed middiu closed 1 year ago

middiu commented 2 years ago

Hi Guys,

I'd need your help to understand what is wrong with my Github Workflow.

I have a dotnet 6 Az Function project that has been running for weeks. Before I was using Azure DevOps Pipelines for deployment and everything was working fine. Now I migrated my repo to Github and I'm trying to deploy the app using Github Actions.

The issue is when I deploy the Function App from Github, the action itself complete successfully but when invoked ALL the Functions raise an exception: The requested service 'XXXXXX' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

Yes I do use Autofac for DI, but when I deploy from Visual Studio, Visual Studio Code or from Azure DevOps pipelines everything works fine, so it must be something related to how I compile/publish the function app in this workflow

This is Action: `jobs: build-and-deploy: runs-on: windows-latest environment: dev steps:

I also tried setting scm-do-build-during-deployment and enable-oryx-build to true but the result doesn't change.

Any idea? Anything I can try?

Cheers

patelchandni commented 2 years ago

@middiu Here is a reference template for steps before functions-actions: https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/windows-dotnet-functionapp-on-azure.yml

middiu commented 2 years ago

@middiu Here is a reference template for steps before functions-actions: https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/windows-dotnet-functionapp-on-azure.yml

This is exactly where I started from, and the issue was still there.

Any idea?

github-actions[bot] commented 2 years ago

This issue is idle because it has been open for 14 days with no activity.

patelchandni commented 1 year ago

@middiu Firstly, there is a typo in your template: Change from "#package" to "package". You cannot comment a required parameter.

Second, are you trying to switch between publish profiles for 2 slots? If so, then you will have to add slot-name parameter for functions-action task: slot-name: This parameter is the slot name to be deployed to. By default, this value is empty, which means the GitHub Action will deploy to your main production site. When this setting points to a non-production slot, please ensure the publish-profile parameter contains the credentials from the function app slot instead of the main production site.

vikanirav commented 1 year ago

Hi,

I am also having same issue for dotnet 6 Az Function project. It is working if it deployed from Visual Studio 22 local machine. But, It is not working if it deployed thourgh Github Actions.

I used below same template for Github Action.

https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/windows-dotnet-functionapp-on-azure.yml

Can anyone please help to solve this issue?

DanielTillmannTR commented 1 month ago

Hi, I am encountering the same issue. dotnet 8.0 Az Function project. It works if it is published from local VSE 2022 but does not work when it is published from GH Actions.