hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.53k stars 4.61k forks source link

"The async operation failed." (azurerm_mssql_managed_instance) #18922

Open JCP13 opened 1 year ago

JCP13 commented 1 year ago

Is there an existing issue for this?

Community Note

Terraform Version

1.3.3

AzureRM Provider Version

3.28.0

Affected Resource(s)/Data Source(s)

azurerm_virtual_network_gateway

Terraform Configuration Files

Here is an example code that I took from Hashcorp:
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_managed_instance

Debug Output/Panic Output

╷
││ Error: waiting for creation of Managed Instance: (Name "tableau-mssql" / Resource Group "tableau-rg"): Code="Failed" Message="The async operation failed." AdditionalInfo=[{"id":"/subscriptions/””/resourceGroups/tableau-rg/providers/Microsoft.Sql/managedInstances/tableau-mssql","location":"westus3","name":"tableau-mssql","properties":{"administratorLogin":"mradministrator","collation":"SQL_Latin1_General_CP1_CI_AS","licenseType":"BasePrice","maintenanceConfigurationId":"/subscriptions/””/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default","minimalTlsVersion":"1.2","privateEndpointConnections":[],"provisioningState":"Failed","proxyOverride":"Default","publicDataEndpointEnabled":false,"state":"CreationFailed","storageAccountType":"GRS","storageSizeInGB":32,"subnetId":"/subscriptions/''/resourceGroups/tableau-rg/providers/Microsoft.Network/virtualNetworks/vnet-tableau/subnets/tableau-mssql-Subnet","timezoneId":"UTC","vCores":4,"zoneRedundant":false},"sku":{"capacity":4,"family":"Gen5","name":"GP_Gen5","tier":"GeneralPurpose"},"tags":{},"type":"Microsoft.Sql/managedInstances"}]
│
│   with azurerm_mssql_managed_instance.mssql,
│   on 04-01-MSSQL.tf line 1, in resource "azurerm_mssql_managed_instance" "mssql":
│    1: resource "azurerm_mssql_managed_instance" "mssql" {
│
│ waiting for creation of Managed Instance: (Name "tableau-mssql" / Resource Group "tableau-rg"): Code="Failed" Message="The async operation failed."
│ AdditionalInfo=[{"id":"/subscriptions/””/resourceGroups/tableau-rg/providers/Microsoft.Sql/managedInstances/tableau-mssql","location":"westus3","name":"tableau-mssql","properties":{"administratorLogin":"mradministrator","collation":"SQL_Latin1_General_CP1_CI_AS","licenseType":"BasePrice","maintenanceConfigurationId":"/subscriptions/””/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default","minimalTlsVersion":"1.2","privateEndpointConnections":[],"provisioningState":"Failed","proxyOverride":"Default","publicDataEndpointEnabled":false,"state":"CreationFailed","storageAccountType":"GRS","storageSizeInGB":32,"subnetId":"/subscriptions/''/resourceGroups/tableau-rg/providers/Microsoft.Network/virtualNetworks/vnet-tableau/subnets/tableau-mssql-Subnet","timezoneId":"UTC","vCores":4,"zoneRedundant":false},"sku":{"capacity":4,"family":"Gen5","name":"GP_Gen5","tier":"GeneralPurpose"},"tags":{},"type":"Microsoft.Sql/managedInstances"}]

Expected Behaviour

The provision of the azurerm_virtual_network_gateway is to be successful.

Actual Behaviour

╷ ││ Error: waiting for creation of Managed Instance: (Name "tableau-mssql" / Resource Group "tableau-rg"): Code="Failed" Message="The async operation failed." AdditionalInfo=[{"id":"/subscriptions/””/resourceGroups/tableau-rg/providers/Microsoft.Sql/managedInstances/tableau-mssql","location":"westus3","name":"tableau-mssql","properties":{"administratorLogin":"mradministrator","collation":"SQL_Latin1_General_CP1_CI_AS","licenseType":"BasePrice","maintenanceConfigurationId":"/subscriptions/””/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default","minimalTlsVersion":"1.2","privateEndpointConnections":[],"provisioningState":"Failed","proxyOverride":"Default","publicDataEndpointEnabled":false,"state":"CreationFailed","storageAccountType":"GRS","storageSizeInGB":32,"subnetId":"/subscriptions/''/resourceGroups/tableau-rg/providers/Microsoft.Network/virtualNetworks/vnet-tableau/subnets/tableau-mssql-Subnet","timezoneId":"UTC","vCores":4,"zoneRedundant":false},"sku":{"capacity":4,"family":"Gen5","name":"GP_Gen5","tier":"GeneralPurpose"},"tags":{},"type":"Microsoft.Sql/managedInstances"}] │ │ with azurerm_mssql_managed_instance.mssql, │ on 04-01-MSSQL.tf line 1, in resource "azurerm_mssql_managed_instance" "mssql": │ 1: resource "azurerm_mssql_managed_instance" "mssql" { │ │ waiting for creation of Managed Instance: (Name "tableau-mssql" / Resource Group "tableau-rg"): Code="Failed" Message="The async operation failed." │ AdditionalInfo=[{"id":"/subscriptions/””/resourceGroups/tableau-rg/providers/Microsoft.Sql/managedInstances/tableau-mssql","location":"westus3","name":"tableau-mssql","properties":{"administratorLogin":"mradministrator","collation":"SQL_Latin1_General_CP1_CI_AS","licenseType":"BasePrice","maintenanceConfigurationId":"/subscriptions/””/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default","minimalTlsVersion":"1.2","privateEndpointConnections":[],"provisioningState":"Failed","proxyOverride":"Default","publicDataEndpointEnabled":false,"state":"CreationFailed","storageAccountType":"GRS","storageSizeInGB":32,"subnetId":"/subscriptions/''/resourceGroups/tableau-rg/providers/Microsoft.Network/virtualNetworks/vnet-tableau/subnets/tableau-mssql-Subnet","timezoneId":"UTC","vCores":4,"zoneRedundant":false},"sku":{"capacity":4,"family":"Gen5","name":"GP_Gen5","tier":"GeneralPurpose"},"tags":{},"type":"Microsoft.Sql/managedInstances"}]

Steps to Reproduce

please run this code: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/mssql_managed_instance

Important Factoids

No response

References

No response

sinbai commented 1 year ago

@JCP13 thanks for opening this issue. Per the error provided above, the error states that the config value for next_hop_type should be VnetLocal instead of vnetlocal. It is case sensitive. Could you update it and try again?

JCP13 commented 1 year ago

My apologies @sinbai,

I copied the wrong error messages. I edit the issue with the correct one. A solution was found. As it turn out it had to do with the password, it was not complex enough so it failed but did not provided a proper error message. Once I created an acceptable password, I was able to create the MSSQL MI.

Thank you for looking into it.

Cheers.

JCP13 commented 1 year ago

Hello, will anyone look into fixing the error message issue?

JCP13 commented 1 year ago

@sinbai will someone look into fixing the error message issue?

manicminer commented 1 year ago

Hi, thanks for reporting this. Whilst at the moment it's not feasible for us to fix the handling of this error message, we may be able to improve on the handling in future when we move away from the go-autorest transport SDK.

roostursauce commented 6 months ago

I have been getting this same error message in azurerm version 3.96.0 and wanted to include a work around for people encountering this issue and running across this article.

When getting this error message with a azurerm_mssql_managed_instance resource, from the Azure Portal go to Subscriptions > choose the subscription you are deploying this terraform resource to > Check Activity Logs. (Note: You may need to give the log 5 minutes before it will populate the failure.)

From the subscription Activity log you will see a failure event such as "Prepares a subnet by applying necessary Network Policies". If you open there error it is not terribly descriptive, but when you click on the JSON tab, it will provide a Properties field that will tell you more about the error encountered.

Example: "submissionTimestamp": "2024-03-28T16:08:36Z", "subscriptionId": "", "tenantId": "", "properties": { "statusMessage": "{\"status\":\"Failed\",\"error\":{\"code\":\"ResourceOperationFailure\",\"message\":\"The resource operation completed with terminal provisioning state 'Failed'.\",\"details\":[{\"code\":\"PrepareNetworkPoliciesDoesnotSupportSubnetsWithoutRouteTable\",\"message\":\"Prepare Network Policies operation doesn't support Subnets /subscriptions//resourceGroups/example-prod-ukwest/providers/Microsoft.Network/virtualNetworks/vnet-example-prod-ukwest/subnets/snet-sqlexample-prod-ukwest without Route Table.\",\"details\":[]}]}}",

In the above example, though it looks like the subnet was not created with the proper delegation settings for the SQL MI resource, by reviewing the properties field, it is clear that the issue is with a separate dependent resource, namely a route table and its association, with the target subnet used by the MI.

Hopefully this will assist others in drilling into this vague error and potentially serve as a source of truth that the Terraform azurerm module in the future, should a fix be possible.