azure-functions-openapi-extension
azure-functions-openapi-extension copied to clipboard
Error with loading file Microsoft.Azure.WebJobs.Extensions.Http.dll
I'm using 0.7.2-preview version and I get this error when I go to URL /swagger/ui
The assemble is available in bin/Debug/netcore3.1/ directory but not in bin/Debug/netcore3.1/bin/.
I tried manually copying this file to the bin/Debug/netcore3.1/bin/ directory. The error goes away then, but I see an empty API definition.
@Ashan-FCC Thanks for the issue! Would you please try the new release, v0.8.1-preview and let me know?
If the same issue still persists, please let me know how to reproduce your issue on my end.
@justinyoo I was able to reproduce the same behavior as @Ashan-FCC on v0.8.1-preview
The http dll is missing from bin/Debug/netcore3.1/bin/
Core Tools Version: 3.0.3442 Function Runtime Version: 3.0.15417.0
Alright. Would you please provide steps you've reproduced this error, so that I can follow the steps?
Ok I did something super simple. I followed the instructions defined here: https://github.com/Azure/azure-functions-openapi-extension/blob/main/docs/enable-open-api-endpoints-in-proc.md
-
Installed the lib on my project v0.8.1-preview. Code snippets from my csproj
<TargetFramework>netcoreapp3.1</TargetFramework> <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.OpenApi" Version="0.8.1-preview" />
-
The class I'm trying to test looks like this. (sorry for the screenshot). The class and the functions are not static. Do I have to have the rest of the functions marked as ignore? Bc they are not. Only this one has the decorators, Just in case.
-
Run the functions app on my http://localhost:7071
-
Navigate to http://localhost:7071/api/swagger/ui
-
Then the console throws the assembly error and the ui says error
Thanks @justinyoo
@alinapach Could you confirm whether your bin/Debug/netcoreapp3.1
and bin/Debug/netcoreapp3.1/bin
directories have only one *.deps.json
file or multiple *.deps.json
files?
Getting this on my end as well. I'm able to reproduce just by using the starter that visual studio provides and removing all of the static keywords
There are possibly two causes on this issue:
-
If there are multiple
*.deps.json
files within yourbin/Debug/netcoreapp3.1
orbin/Debug/netcoreapp3.1/bin
directory, it might be the one, as mentioned above. -
Try this approach on your
.csproj
file, which is a sort of official workaround for the time being:<PropertyGroup> ... <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup>
There are possibly two causes on this issue:
- If there are multiple
*.deps.json
files within yourbin/Debug/netcoreapp3.1
orbin/Debug/netcoreapp3.1/bin
directory, it might be the one, as mentioned above.- Try this approach on your
.csproj
file, which is a sort of official workaround for the time being:<PropertyGroup> ... <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup>
It is easy to reproduce the bug, and the _FunctionsSkipCleanOutput didn't work for me.
steps:
- follow the article https://techcommunity.microsoft.com/t5/apps-on-azure/create-and-publish-openapi-enabled-azure-functions-with-visual/ba-p/2381067 to create a template project with OpenApi 0.7.2-preview.
- change the openapi to 0.8.1-preview (optional)
- add
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />
to the project. - press F5 to start debugging, then visit http://localhost:7071/api/swagger/ui you will get error
Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.12.0
- add
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
to the project - visit http://localhost:7071/api/swagger/ui again, it seems work and the assembly is fine right now. but you will get
No operations defined in spec!
which mean there is nothing in the openapi document.
We did some research and find out it could be this code
Where(p => p.GetParameters().FirstOrDefault(q => q.ExistsCustomAttribute<HttpTriggerAttribute>()) != null)
HttpTriggerAttribute may have 3.0.2 and 3.0.12 conflict.
A possible solution for me is to downgrade Microsoft.Azure.WebJobs.Extensions.Http to 3.0.2
Wish my practice can help.
There are possibly two causes on this issue:
- If there are multiple
*.deps.json
files within yourbin/Debug/netcoreapp3.1
orbin/Debug/netcoreapp3.1/bin
directory, it might be the one, as mentioned above.- Try this approach on your
.csproj
file, which is a sort of official workaround for the time being:<PropertyGroup> ... <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup>
It is easy to reproduce the bug, and the _FunctionsSkipCleanOutput didn't work for me.
steps:
- follow the article https://techcommunity.microsoft.com/t5/apps-on-azure/create-and-publish-openapi-enabled-azure-functions-with-visual/ba-p/2381067 to create a template project with OpenApi 0.7.2-preview.
- change the openapi to 0.8.1-preview (optional)
- add
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />
to the project.- press F5 to start debugging, then visit http://localhost:7071/api/swagger/ui you will get error
Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.12.0
- add
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
to the project- visit http://localhost:7071/api/swagger/ui again, it seems work and the assembly is fine right now. but you will get
No operations defined in spec!
which mean there is nothing in the openapi document.We did some research and find out it could be this code
Where(p => p.GetParameters().FirstOrDefault(q => q.ExistsCustomAttribute<HttpTriggerAttribute>()) != null)
HttpTriggerAttribute may have 3.0.2 and 3.0.12 conflict.A possible solution for me is to downgrade Microsoft.Azure.WebJobs.Extensions.Http to 3.0.2
Wish my practice can help.
This exactly. I was able to resolve my issues when I removed a package reference that used 3.0.12. (In this case, I was using a third-party package to generate open api documents in the past and we were migrating to this package because of another bug...) When I removed the package, all references were downgraded to 3.0.2 and my problems went away
There are possibly two causes on this issue:
- If there are multiple
*.deps.json
files within yourbin/Debug/netcoreapp3.1
orbin/Debug/netcoreapp3.1/bin
directory, it might be the one, as mentioned above.- Try this approach on your
.csproj
file, which is a sort of official workaround for the time being:<PropertyGroup> ... <_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput> </PropertyGroup>
It is easy to reproduce the bug, and the _FunctionsSkipCleanOutput didn't work for me.
steps:
- follow the article https://techcommunity.microsoft.com/t5/apps-on-azure/create-and-publish-openapi-enabled-azure-functions-with-visual/ba-p/2381067 to create a template project with OpenApi 0.7.2-preview.
- change the openapi to 0.8.1-preview (optional)
- add
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />
to the project.- press F5 to start debugging, then visit http://localhost:7071/api/swagger/ui you will get error
Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.12.0
- add
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
to the project- visit http://localhost:7071/api/swagger/ui again, it seems work and the assembly is fine right now. but you will get
No operations defined in spec!
which mean there is nothing in the openapi document.We did some research and find out it could be this code
Where(p => p.GetParameters().FirstOrDefault(q => q.ExistsCustomAttribute<HttpTriggerAttribute>()) != null)
HttpTriggerAttribute may have 3.0.2 and 3.0.12 conflict.A possible solution for me is to downgrade Microsoft.Azure.WebJobs.Extensions.Http to 3.0.2
Wish my practice can help.
How do you know the API conflicts?