Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update documents #81

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
{
"schema_version": 0,
"attributes": {
"body": "{\"properties\":{\"publicNetworkAccess\":\"Enabled\",\"utilityStorageAccountId\":\"/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001/providers/Microsoft.Storage/storageAccounts/acctest0001\"}}",
"id": "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001/providers/Microsoft.Migrate/migrateProjects/acctest0001",
"body": "{\"properties\":{\"publicNetworkAccess\":\"Enabled\",\"utilityStorageAccountId\":\"/subscriptions/******/resourceGroups/acctest0001/providers/Microsoft.Storage/storageAccounts/acctest0001\"}}",
"id": "/subscriptions/******/resourceGroups/acctest0001/providers/Microsoft.Migrate/migrateProjects/acctest0001",
"identity": [],
"ignore_casing": false,
"ignore_changes": null,
Expand All @@ -24,7 +24,7 @@
"locks": null,
"name": "acctest0001",
"output": "{}",
"parent_id": "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001",
"parent_id": "/subscriptions/******/resourceGroups/acctest0001",
"removing_special_chars": false,
"response_export_values": null,
"schema_validation_enabled": true,
Expand All @@ -51,16 +51,16 @@
"schema_version": 0,
"attributes": {
"body": "{}",
"id": "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001",
"id": "/subscriptions/******/resourceGroups/acctest0001",
"identity": [],
"ignore_casing": false,
"ignore_changes": null,
"ignore_missing_property": true,
"location": "westeurope",
"locks": null,
"name": "acctest0001",
"output": "{\"id\":\"/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001\",\"location\":\"westeurope\",\"name\":\"acctest0001\",\"properties\":{\"provisioningState\":\"Succeeded\"},\"type\":\"Microsoft.Resources/resourceGroups\"}",
"parent_id": "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76",
"output": "{\"id\":\"/subscriptions/******/resourceGroups/acctest0001\",\"location\":\"westeurope\",\"name\":\"acctest0001\",\"properties\":{\"provisioningState\":\"Succeeded\"},\"type\":\"Microsoft.Resources/resourceGroups\"}",
"parent_id": "/subscriptions/******",
"removing_special_chars": false,
"response_export_values": [
"*"
Expand All @@ -85,7 +85,7 @@
"schema_version": 0,
"attributes": {
"body": "{\"properties\":{\"summary\":{\"instanceType\":\"Servers\",\"migratedCount\":0}}}",
"id": "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001/providers/Microsoft.Migrate/migrateProjects/acctest0001/solutions/acctest0001",
"id": "/subscriptions/******/resourceGroups/acctest0001/providers/Microsoft.Migrate/migrateProjects/acctest0001/solutions/acctest0001",
"identity": [],
"ignore_casing": false,
"ignore_changes": null,
Expand All @@ -94,7 +94,7 @@
"locks": null,
"name": "acctest0001",
"output": "{}",
"parent_id": "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001/providers/Microsoft.Migrate/migrateProjects/acctest0001",
"parent_id": "/subscriptions/******/resourceGroups/acctest0001/providers/Microsoft.Migrate/migrateProjects/acctest0001",
"removing_special_chars": false,
"response_export_values": null,
"schema_validation_enabled": true,
Expand Down Expand Up @@ -122,7 +122,7 @@
"schema_version": 0,
"attributes": {
"body": "{\"identity\":{\"type\":\"None\"},\"kind\":\"StorageV2\",\"properties\":{\"accessTier\":\"Hot\",\"allowBlobPublicAccess\":true,\"allowCrossTenantReplication\":true,\"allowSharedKeyAccess\":true,\"defaultToOAuthAuthentication\":false,\"encryption\":{\"keySource\":\"Microsoft.Storage\",\"services\":{\"queue\":{\"keyType\":\"Service\"},\"table\":{\"keyType\":\"Service\"}}},\"isHnsEnabled\":false,\"isNfsV3Enabled\":false,\"isSftpEnabled\":false,\"minimumTlsVersion\":\"TLS1_2\",\"networkAcls\":{\"defaultAction\":\"Allow\"},\"publicNetworkAccess\":\"Enabled\",\"supportsHttpsTrafficOnly\":true},\"sku\":{\"name\":\"Standard_LRS\"}}",
"id": "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001/providers/Microsoft.Storage/storageAccounts/acctest0001",
"id": "/subscriptions/******/resourceGroups/acctest0001/providers/Microsoft.Storage/storageAccounts/acctest0001",
"identity": [
{
"identity_ids": [],
Expand All @@ -137,8 +137,8 @@
"location": "westeurope",
"locks": null,
"name": "acctest0001",
"output": "{\"id\":\"/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001/providers/Microsoft.Storage/storageAccounts/acctest0001\",\"identity\":{\"type\":\"None\"},\"kind\":\"StorageV2\",\"location\":\"westeurope\",\"name\":\"acctest0001\",\"properties\":{\"accessTier\":\"Hot\",\"allowBlobPublicAccess\":true,\"allowCrossTenantReplication\":true,\"allowSharedKeyAccess\":true,\"creationTime\":\"2023-08-10T04:15:22.6959214Z\",\"defaultToOAuthAuthentication\":false,\"encryption\":{\"keySource\":\"Microsoft.Storage\",\"services\":{\"blob\":{\"enabled\":true,\"keyType\":\"Account\",\"lastEnabledTime\":\"2023-08-10T04:15:23.1647234Z\"},\"file\":{\"enabled\":true,\"keyType\":\"Account\",\"lastEnabledTime\":\"2023-08-10T04:15:23.1647234Z\"}}},\"isHnsEnabled\":false,\"isNfsV3Enabled\":false,\"isSftpEnabled\":false,\"keyCreationTime\":{\"key1\":\"2023-08-10T04:15:22.8834265Z\",\"key2\":\"2023-08-10T04:15:22.8834265Z\"},\"minimumTlsVersion\":\"TLS1_2\",\"networkAcls\":{\"bypass\":\"AzureServices\",\"defaultAction\":\"Allow\",\"ipRules\":[],\"virtualNetworkRules\":[]},\"primaryEndpoints\":{\"blob\":\"https://acctest0001.blob.core.windows.net/\",\"dfs\":\"https://acctest0001.dfs.core.windows.net/\",\"file\":\"https://acctest0001.file.core.windows.net/\",\"queue\":\"https://acctest0001.queue.core.windows.net/\",\"table\":\"https://acctest0001.table.core.windows.net/\",\"web\":\"https://acctest0001.z6.web.core.windows.net/\"},\"primaryLocation\":\"westeurope\",\"privateEndpointConnections\":[],\"provisioningState\":\"Succeeded\",\"publicNetworkAccess\":\"Enabled\",\"statusOfPrimary\":\"available\",\"supportsHttpsTrafficOnly\":true},\"sku\":{\"name\":\"Standard_LRS\",\"tier\":\"Standard\"},\"tags\":{},\"type\":\"Microsoft.Storage/storageAccounts\"}",
"parent_id": "/subscriptions/85b3dbca-5974-4067-9669-67a141095a76/resourceGroups/acctest0001",
"output": "{\"id\":\"/subscriptions/******/resourceGroups/acctest0001/providers/Microsoft.Storage/storageAccounts/acctest0001\",\"identity\":{\"type\":\"None\"},\"kind\":\"StorageV2\",\"location\":\"westeurope\",\"name\":\"acctest0001\",\"properties\":{\"accessTier\":\"Hot\",\"allowBlobPublicAccess\":true,\"allowCrossTenantReplication\":true,\"allowSharedKeyAccess\":true,\"creationTime\":\"2023-08-10T04:15:22.6959214Z\",\"defaultToOAuthAuthentication\":false,\"encryption\":{\"keySource\":\"Microsoft.Storage\",\"services\":{\"blob\":{\"enabled\":true,\"keyType\":\"Account\",\"lastEnabledTime\":\"2023-08-10T04:15:23.1647234Z\"},\"file\":{\"enabled\":true,\"keyType\":\"Account\",\"lastEnabledTime\":\"2023-08-10T04:15:23.1647234Z\"}}},\"isHnsEnabled\":false,\"isNfsV3Enabled\":false,\"isSftpEnabled\":false,\"keyCreationTime\":{\"key1\":\"2023-08-10T04:15:22.8834265Z\",\"key2\":\"2023-08-10T04:15:22.8834265Z\"},\"minimumTlsVersion\":\"TLS1_2\",\"networkAcls\":{\"bypass\":\"AzureServices\",\"defaultAction\":\"Allow\",\"ipRules\":[],\"virtualNetworkRules\":[]},\"primaryEndpoints\":{\"blob\":\"https://acctest0001.blob.core.windows.net/\",\"dfs\":\"https://acctest0001.dfs.core.windows.net/\",\"file\":\"https://acctest0001.file.core.windows.net/\",\"queue\":\"https://acctest0001.queue.core.windows.net/\",\"table\":\"https://acctest0001.table.core.windows.net/\",\"web\":\"https://acctest0001.z6.web.core.windows.net/\"},\"primaryLocation\":\"westeurope\",\"privateEndpointConnections\":[],\"provisioningState\":\"Succeeded\",\"publicNetworkAccess\":\"Enabled\",\"statusOfPrimary\":\"available\",\"supportsHttpsTrafficOnly\":true},\"sku\":{\"name\":\"Standard_LRS\",\"tier\":\"Standard\"},\"tags\":{},\"type\":\"Microsoft.Storage/storageAccounts\"}",
"parent_id": "/subscriptions/******/resourceGroups/acctest0001",
"removing_special_chars": false,
"response_export_values": [
"*"
Expand Down
206 changes: 206 additions & 0 deletions docs/fix-errors/Microsoft.Purview_accounts_InvalidRequestContent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# Fix Error Example - Microsoft.Purview/accounts - 400 InvalidRequestContent

## Error Message

```shell
ERRO[0109] error running terraform apply: exit status 1

Error: performing action of "Resource: (ResourceId \"/subscriptions/******/resourceGroups/acctest5906/providers/Microsoft.Purview/accounts/acctest5906\" / Api Version \"2021-12-01\")": PATCH https://management.azure.com/subscriptions/******/resourceGroups/acctest5906/providers/Microsoft.Purview/accounts/acctest5906
--------------------------------------------------------------------------------
RESPONSE 400: 400 Bad Request
ERROR CODE: InvalidRequestContent
--------------------------------------------------------------------------------
{
"error": {
"code": "InvalidRequestContent",
"message": "The request content was invalid and could not be deserialized: 'Could not find member 'cloudConnectors' on object of type 'ResourceDefinition'. Path 'cloudConnectors', line 1, position 20.'."
}
}
--------------------------------------------------------------------------------


with azapi_resource_action.patch_account,
on main.tf line 51, in resource "azapi_resource_action" "patch_account":
51: resource "azapi_resource_action" "patch_account" {

```

## Config that triggers the error

```hcl
resource "azapi_resource_action" "patch_account" {
type = "Microsoft.Purview/accounts@2021-12-01"
resource_id = azapi_resource.account.id
action = ""
method = "PATCH"
body = jsonencode({
cloudConnectors = {
}
managedResourceGroupName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
managedResourcesPublicNetworkAccess = "Disabled"
publicNetworkAccess = "NotSpecified"
})
}
```


## Solution

In above config, the `cloudConnectors`, `managedResourceGroupName`, `managedResourcesPublicNetworkAccess` and `publicNetworkAccess` should be under the `properties` bag, not the root of the body. The following config will fix the error.

```hcl
resource "azapi_resource_action" "patch_account" {
type = "Microsoft.Purview/accounts@2021-12-01"
resource_id = azapi_resource.account.id
action = ""
method = "PATCH"
body = jsonencode({
properties = {
cloudConnectors = {
}
managedResourceGroupName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
managedResourcesPublicNetworkAccess = "Disabled"
publicNetworkAccess = "NotSpecified"
}
})
}
```


## Terraform config

```hcl
terraform {
required_providers {
azapi = {
source = "Azure/azapi"
}
}
}

provider "azapi" {
skip_provider_registration = false
}

variable "resource_name" {
type = string
default = "acctest5906"
}

variable "location" {
type = string
default = "West US 2"
}

resource "azapi_resource" "resourceGroup" {
type = "Microsoft.Resources/resourceGroups@2020-06-01"
name = var.resource_name
location = var.location
}

// OperationId: Accounts_CreateOrUpdate, Accounts_Get, Accounts_Delete
// PUT GET DELETE /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}
resource "azapi_resource" "account" {
type = "Microsoft.Purview/accounts@2021-12-01"
parent_id = azapi_resource.resourceGroup.id
name = var.resource_name
location = var.location
identity {
type = "SystemAssigned"
identity_ids = []
}
body = jsonencode({
properties = {
managedResourceGroupName = "custom-rgname"
managedResourcesPublicNetworkAccess = "Enabled"
}
})
schema_validation_enabled = false
}

// OperationId: Accounts_Update
// PATCH /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}
resource "azapi_resource_action" "patch_account" {
type = "Microsoft.Purview/accounts@2021-12-01"
resource_id = azapi_resource.account.id
action = ""
method = "PATCH"
body = jsonencode({
# ========== fix: add the following configs ==========
properties = {
cloudConnectors = {
}
managedResourceGroupName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
managedResourcesPublicNetworkAccess = "Disabled"
publicNetworkAccess = "NotSpecified"
}
# ========== fix ==========
# ========== fix: remove the following configs ==========
cloudConnectors = {
}
managedResourceGroupName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
managedResourcesPublicNetworkAccess = "Disabled"
publicNetworkAccess = "NotSpecified"
# ========== fix ==========
})
}

// OperationId: Accounts_AddRootCollectionAdmin
// POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/addRootCollectionAdmin
resource "azapi_resource_action" "addRootCollectionAdmin" {
type = "Microsoft.Purview/accounts@2021-12-01"
resource_id = azapi_resource.account.id
action = "addRootCollectionAdmin"
method = "POST"
body = jsonencode({
objectId = "7e8de0e7-2bfc-4e1f-9659-2a5785e4356f"
})
}

// OperationId: Features_AccountGet
// POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/listFeatures
resource "azapi_resource_action" "listFeatures" {
type = "Microsoft.Purview/accounts@2021-12-01"
resource_id = azapi_resource.account.id
action = "listFeatures"
method = "POST"
body = jsonencode({
features = [
"Feature1",
"Feature2",
"FeatureThatDoesntExist",
]
})
}

// OperationId: Accounts_ListKeys
// POST /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts/{accountName}/listkeys
resource "azapi_resource_action" "listkeys" {
type = "Microsoft.Purview/accounts@2021-12-01"
resource_id = azapi_resource.account.id
action = "listkeys"
method = "POST"
}

data "azapi_resource" "subscription" {
type = "Microsoft.Resources/subscriptions@2020-06-01"
response_export_values = ["*"]
}

// OperationId: Accounts_ListBySubscription
// GET /subscriptions/{subscriptionId}/providers/Microsoft.Purview/accounts
data "azapi_resource_list" "listAccountsBySubscription" {
type = "Microsoft.Purview/accounts@2021-12-01"
parent_id = data.azapi_resource.subscription.id
depends_on = [azapi_resource.account]
}

// OperationId: Accounts_ListByResourceGroup
// GET /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Purview/accounts
data "azapi_resource_list" "listAccountsByResourceGroup" {
type = "Microsoft.Purview/accounts@2021-12-01"
parent_id = azapi_resource.resourceGroup.id
depends_on = [azapi_resource.account]
}

```
Loading
Loading