Azure / Azure/azure-rest-api-specs

BadRequest when Create Or Update Host Secret (aka Api Key) for Function App

Open
#14,557 8 comments 2 reactions 0 assignees View on GitHub
bug Functions Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

### Bug Report

- What happened?
I think the best way to describe the bug is by pointing towards a blog which explains how to circumvent this bug: https://tomaszoledzki.eu/2020/07/24/badrequest-error-function-app-create-or-update-host-secret/.

Using the Go SDK I want to create/update a Host Secret for a Function App:
```
PUT /subscriptions//resourceGroups/acctestRG-210526205240104071/providers/Microsoft.Web/sites/acctest-210526205240104071-func/host/default/functionKeys/default?api-version=2020-06-01 HTTP/1.1
Host: management.azure.com
User-Agent: Go/go1.16.3 (amd64-darwin) go-autorest/v14.2.1 Azure-SDK-For-Go/v54.3.0 web/2020-06-01 HashiCorp Terraform/0.15.4 (+https://www.terraform.io) Terraform Plugin SDK/1.17.2 terraform-provider-azurerm/acc pid-222c6c49-1b0a-5959-a213-6608f9eb8820
Content-Length: 18
Content-Type: application/json; charset=utf-8
X-Ms-Correlation-Request-Id: bb865f8a-0e66-6eb4-14dd-43f52886532b
Accept-Encoding: gzip

{"name": "default", "value":"123234"}
```

The response is like this:

```json
{
"Code": "BadRequest",
"Message": "Properties object is not present in the request body.",
"Target": null,
"Details": [
{
"Message": "Properties object is not present in the request body."
},
{
"Code": "BadRequest"
},
{
"ErrorEntity": {
"ExtendedCode": "51006",
"MessageTemplate": "{0} object is not present in the request body.",
"Parameters": [
"Properties"
],
"Code": "BadRequest",
"Message": "Properties object is not present in the request body."
}
}
],
"Innererror": null
}
```
- What did you expect or want to happen?
I expect the Go SDK/REST API to handle this and the specification to be right, but apparently it needs a body with a `properties` wrapper, like:

```json
{
"properties": {
"name": "default",
"value": "123234"
}
}
```
- How can we reproduce it?
Create a function app and use [this](https://tomaszoledzki.eu/2020/07/25/function-app-create-or-update-host-secret/) or similar without the `properties` wrapper
- Anything we should know about your environment.
I'm trying to add a HostSecret resource for the Azure Terraform Provider

Contributor guide

Open the contributing guide

Research direction

Start from the reported PUT endpoint for the Function App host secret and compare the request schema with the two linked examples. Locate the corresponding Azure REST API specification and verify how the request body is represented. Done means the specification accurately reflects the required properties wrapper and the resulting request can be validated against the reported API behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.