[BUG] Publisher gets 400 Putting Backends
Release version
v6.0.1.4
Describe the bug
Hi,
I'm executing run-publisher-with-env.yaml pipeline and during the Run Publisher task, the Publisher is failing with the following stackstrace:
2025-03-13T09:34:17.1971177Z crit: publisher[0]
2025-03-13T09:34:17.1971989Z Application failed.
2025-03-13T09:34:17.1973854Z System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/***/xxxxxxxx failed with status code 400. Content is '{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"credentials","message":"Property 'func-xxx-xxxx-xxxx-xxx-xxxx-key' not found."}]}}'.
2025-03-13T09:34:17.1974692Z at common.HttpPipelineExtensions.<>c__DisplayClass11_0.<PutContent>b__0(Response response) in /home/runner/work/apiops/apiops/tools/code/common/Http.cs:line 173
2025-03-13T09:34:17.1976368Z at LanguageExt.Either.Left`2.Match[B](Func`2 Left, Func`2 Right)
2025-03-13T09:34:17.1976942Z at common.HttpPipelineExtensions.PutContent(HttpPipeline pipeline, Uri uri, BinaryData content, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Http.cs:line 173
2025-03-13T09:34:17.1977363Z at common.BackendModule.PutDto(BackendUri uri, BackendDto dto, HttpPipeline pipeline, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Backend.cs:line 415
2025-03-13T09:34:17.1977834Z at publisher.BackendModule.<>c__DisplayClass11_0.<<GetPutBackendInApim>b__0>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/Backend.cs:line 172
2025-03-13T09:34:17.1978134Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.1978421Z at publisher.BackendModule.<>c__DisplayClass7_1.<<GetPutBackend>b__1>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/Backend.cs:line 121
2025-03-13T09:34:17.1978701Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.1979001Z at common.OptionExtensions.IterTask[T](Option`1 option, Func`3 action, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Option.cs:line 22
2025-03-13T09:34:17.1979360Z at common.OptionExtensions.IterTask[T](Option`1 option, Func`2 action) in /home/runner/work/apiops/apiops/tools/code/common/Option.cs:line 16
2025-03-13T09:34:17.1979833Z at publisher.BackendModule.<>c__DisplayClass7_0.<<GetPutBackend>b__0>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/Backend.cs:line 121
2025-03-13T09:34:17.1980115Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.1980345Z at System.Threading.Tasks.Parallel.<>c__53`1.<<ForEachAsync>b__53_0>d.MoveNext()
2025-03-13T09:34:17.1980576Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.1980910Z at common.IEnumerableExtensions.IterParallel[T](IEnumerable`1 enumerable, Func`3 action, Int32 maxDegreeOfParallelism, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Enumerable.cs:line 61
2025-03-13T09:34:17.1981383Z at common.IEnumerableExtensions.IterParallel[T](IEnumerable`1 enumerable, Func`3 action, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Enumerable.cs:line 47
2025-03-13T09:34:17.1981768Z at publisher.BackendModule.<>c__DisplayClass1_0.<<GetPutBackends>b__0>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/Backend.cs:line 54
2025-03-13T09:34:17.1982053Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.1982334Z at publisher.AppModule.<>c__DisplayClass1_0.<<GetRunApplication>b__0>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/App.cs:line 169
2025-03-13T09:34:17.1982649Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.1982925Z at common.HostingModule.RunApplication(IHost host) in /home/runner/work/apiops/apiops/tools/code/common/Hosting.cs:line 89
2025-03-13T09:34:17.1983175Z info: Microsoft.Hosting.Lifetime[0]
2025-03-13T09:34:17.1983362Z Application is shutting down...
2025-03-13T09:34:17.2061880Z Unhandled exception. System.Net.Http.HttpRequestException: HTTP request to URI https://management.azure.com/subscriptions/***/xxxxxxxx failed with status code 400. Content is '{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"credentials","message":"Property 'func-xxx-xxxx-xxxx-xxx-xxxx-key' not found."}]}}'.
2025-03-13T09:34:17.2062697Z at common.HttpPipelineExtensions.<>c__DisplayClass11_0.<PutContent>b__0(Response response) in /home/runner/work/apiops/apiops/tools/code/common/Http.cs:line 173
2025-03-13T09:34:17.2063210Z at LanguageExt.Either.Left`2.Match[B](Func`2 Left, Func`2 Right)
2025-03-13T09:34:17.2063544Z at common.HttpPipelineExtensions.PutContent(HttpPipeline pipeline, Uri uri, BinaryData content, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Http.cs:line 173
2025-03-13T09:34:17.2064074Z at common.BackendModule.PutDto(BackendUri uri, BackendDto dto, HttpPipeline pipeline, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Backend.cs:line 415
2025-03-13T09:34:17.2064557Z at publisher.BackendModule.<>c__DisplayClass11_0.<<GetPutBackendInApim>b__0>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/Backend.cs:line 172
2025-03-13T09:34:17.2064847Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.2065149Z at publisher.BackendModule.<>c__DisplayClass7_1.<<GetPutBackend>b__1>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/Backend.cs:line 121
2025-03-13T09:34:17.2065434Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.2065734Z at common.OptionExtensions.IterTask[T](Option`1 option, Func`3 action, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Option.cs:line 22
2025-03-13T09:34:17.2066094Z at common.OptionExtensions.IterTask[T](Option`1 option, Func`2 action) in /home/runner/work/apiops/apiops/tools/code/common/Option.cs:line 16
2025-03-13T09:34:17.2066443Z at publisher.BackendModule.<>c__DisplayClass7_0.<<GetPutBackend>b__0>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/Backend.cs:line 121
2025-03-13T09:34:17.2066740Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.2066971Z at System.Threading.Tasks.Parallel.<>c__53`1.<<ForEachAsync>b__53_0>d.MoveNext()
2025-03-13T09:34:17.2067204Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.2067541Z at common.IEnumerableExtensions.IterParallel[T](IEnumerable`1 enumerable, Func`3 action, Int32 maxDegreeOfParallelism, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Enumerable.cs:line 61
2025-03-13T09:34:17.2067984Z at common.IEnumerableExtensions.IterParallel[T](IEnumerable`1 enumerable, Func`3 action, CancellationToken cancellationToken) in /home/runner/work/apiops/apiops/tools/code/common/Enumerable.cs:line 47
2025-03-13T09:34:17.2068382Z at publisher.BackendModule.<>c__DisplayClass1_0.<<GetPutBackends>b__0>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/Backend.cs:line 54
2025-03-13T09:34:17.2068664Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.2069076Z at publisher.AppModule.<>c__DisplayClass1_0.<<GetRunApplication>b__0>d.MoveNext() in /home/runner/work/apiops/apiops/tools/code/publisher/App.cs:line 169
2025-03-13T09:34:17.2069355Z --- End of stack trace from previous location ---
2025-03-13T09:34:17.2069614Z at common.HostingModule.RunApplication(IHost host) in /home/runner/work/apiops/apiops/tools/code/common/Hosting.cs:line 89
2025-03-13T09:34:17.2070055Z at common.HostingModule.RunHost(String[] arguments, String applicationName, Action`1 configureRunApplication) in /home/runner/work/apiops/apiops/tools/code/common/Hosting.cs:line 24
2025-03-13T09:34:17.2070418Z at publisher.Program.Main(String[] arguments) in /home/runner/work/apiops/apiops/tools/code/publisher/Program.cs:line 10
2025-03-13T09:34:17.2070676Z at publisher.Program.<Main>(String[] arguments)
I have checked the named values folder of the extracted files and I can find the folder with the same name the log is saying don't find it and the content is similar to this one:
{
"properties": {
"displayName": "func-xxx-xxxx-xxxx-xxx-xxxx-key",
"secret": true,
"tags": [
"key",
"function",
"auto"
]
}
}
And of course I can find that name value on the original APi Management.
Our Azure Functions are being imported in API Management using the wizard, that's why there is a tag "auto"
I'm wondering if this is happening due to the way we are importing our Azure Functions on API Management or because the named values are secrets.
Expected behavior
Expected successful publishing
Actual behavior
{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"credentials","message":"Property 'func-xxx-xxxx-xxxx-xxx-xxxx-key' not found."}]}}
Reproduction Steps
Execute run-publisher-with-env.yaml
Thank you for opening this issue! Please be patient while we will look into it and get back to you as this is an open source project. In the meantime make sure you take a look at the [closed issues](https://github.com/Azure/apiops/issues?q=is%3Aissue+is%3Aclosed) in case your question has already been answered. Don't forget to provide any additional information if needed (e.g. scrubbed logs, detailed feature requests,etc.).
Whenever it's feasible, please don't hesitate to send a Pull Request (PR) our way. We'd greatly appreciate it, and we'll gladly assess and incorporate your changes.