Azure / Azure/terraform-provider-azapi

Support azapi_data_plane_resource in usgovernment cloud with Microsoft.Search

Open
#1,144 1 comment 0 reactions 1 assignee Claimed by @LingyuTang View on GitHub
triaged
Dominant language
Go
Stars
244
Forks
97
Avg merge
5d 9h
Merged PRs (30d)
9

Description

Cannot create object get error 403
```terraform
resource "azapi_data_plane_resource" "srch_datasource" {
type = "Microsoft.Search/searchServices/datasources@2026-04-01"
parent_id = trimprefix(azurerm_search_service.srch.endpoint, "https://")
name = "external-datasource"

body = {
type = "cosmosdb"
credentials = {
connectionString = "${data.azurerm_cosmosdb_account.cosmosdb.primary_sql_connection_string};Database=db"
}
container = {
name = "container"
query = "SELECT * FROM c WHERE c._ts > @HighWaterMark ORDER BY c._ts"
}
}

depends_on = [azurerm_search_service.srch]
}
```
Get Error
azapi_data_plane_resource RESPONSE 403: 403 Forbidden

```
2026-06-16T06:55:05.184+0300 [ERROR] provider.terraform-provider-azapi_v2.10.0.exe: Response contains error diagnostic: diagnostic_severity=ERROR diagnostic_summary="Failed to create/update resource" tf_provider_addr=registry.terraform.io/Azure/azapi tf_req_id=9ae1ebd4-77a2-a299-01ac-c85dcd3475ee tf_resource_type=azapi_data_plane_resource @caller=github.com/hashicorp/terraform-plugin-go@v0.31.0/tfprotov6/internal/diag/diagnostics.go:58 tf_proto_version=6.11 tf_rpc=ApplyResourceChange @module=sdk.proto
diagnostic_detail=
| creating/updating "Resource: (ResourceId \"srch-***********-usgovarizona-001.search.azure.us/datasources('external-datasource')\" / Api Version \"2026-04-01\")": GET https://srch-***********-usgovarizona-001.search.azure.us:443/datasources('external-datasource')
| --------------------------------------------------------------------------------
| RESPONSE 403: 403 Forbidden
| ERROR CODE UNAVAILABLE
| --------------------------------------------------------------------------------
| Response contained no body
| --------------------------------------------------------------------------------
timestamp="2026-06-16T06:55:05.181+0300"
```

I think this problem that get incorrect audience and use https://management.usgovcloudapi.net and not https://search.azure.us

Also
```terraform
read_headers = {
"api-key" = data.azurerm_search_service.srch.primary_key
}
```
ignored and use OAuth

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.