terraform-provider-azapi icon indicating copy to clipboard operation
terraform-provider-azapi copied to clipboard

Microsoft.MachineLearningServices/workspaces/outboundRules returns MissingApiVersionParameter

Open emad0082 opened this issue 9 months ago • 8 comments

Brief description of the problem

When using Microsoft.MachineLearningServices/workspaces/outboundRules@2023-10-01 as documented here to create outbound rules in the workspace. Terraform throws the following error, indicating that the api_version parameter is not set. However the documentation provides the version in the type parameter. The request itself actually has it specified which version is being used, so i dont understand how this error happens in the first place.

When applying the terraform code, an error with the message: RESPONSE 400: 400 Bad Request ERROR CODE: ValidationError happens. - {"error":{"code":"MissingApiVersionParameter","message":"The api-version query parameter (?api-version=) is required for all requests."}}

Terraform code:

resource "azapi_resource" "outbound_rules" {
  type = "Microsoft.MachineLearningServices/workspaces/outboundRules@2023-10-01" 
  name = "CognitiveServiceOutboundRule"
  parent_id = azurerm_machine_learning_workspace.default.id
  locks = [azurerm_machine_learning_workspace.default.id]
  body = jsonencode({
  "properties": {
    "category": "UserDefined",
    "status": "Active",
    "type": "PrivateEndpoint",
    "destination": {
      "serviceResourceId": "${azurerm_private_endpoint.openai_ple.id}",
      "sparkEnabled": false,
      "sparkStatus": "Inactive",
      "subresourceTarget": "account"
      }
    }
  })
}

Full stack trace of the error:

Error: Failed to create/update resource

  with azapi_resource.outbound_rules,
  on workspace.tf line 100, in resource "azapi_resource" "outbound_rules":
 100: resource "azapi_resource" "outbound_rules" {

creating/updating Resource: (ResourceId
"/subscriptions/xxxxx/resourceGroups/xxxxx/providers/Microsoft.MachineLearningServices/workspaces/AIP-SB-Core-mlw/outboundRules/CognitiveServiceOutboundRule"
/ Api Version "20[23](https://github.com/xxxx/actions/runs/xxxxx#step:17:24)-10-01"): PUT


{"error":{"code":"MissingApiVersionParameter","message":"The api-version query parameter (?api-version=) is required for all requests."}}
--------------------------------------------------------------------------------
RESPONSE 400: 400 Bad Request
ERROR CODE: ValidationError
--------------------------------------------------------------------------------
{
  "error": {
    "code": "ValidationError",
    "severity": null,
    "message": "Unsupported Target resource Microsoft.Network/privateEndpoints in Rule: \"CognitiveServiceOutboundRule\". Check documentation for supported types:https://aka.ms/AMLSupportedPEsInManagedNetwork",
    "messageFormat": null,
    "messageParameters": null,
    "referenceCode": null,
    "detailsUri": null,
    "target": null,
    "details": [],
    "innerError": null,
    "debugInfo": null,
    "additionalInfo": null
  },
  "correlation": {
    "operation": "xxxx",
    "request": "4717f16cd1228543"
  },
  "environment": "westeurope",
  "location": "westeurope",
  "time": "2024-05-08T08:55:20.4,
  "componentName": "account-rp",
  "statusCode": 400
}
--------------------------------------------------------------------------------

How to reproduce

Implement a private endpoint, a machine learning workspace in your terraform config. Specify type to this version: type = "Microsoft.MachineLearningServices/workspaces/outboundRules@2023-10-01"

Run the plan.

Apply, and it should fail.

Current workarounds/fixes

As of so far i have not been able to add private endpoint outbound rules to the resource. Any help would be greatly appreciated

emad0082 avatar May 08 '24 09:05 emad0082

How do i add a label to this?

emad0082 avatar May 14 '24 06:05 emad0082

Hi @emad0082 ,

Thank you for taking time to report this issue and apologize for late response.

There's a similar issue related to ML workspace outbound rules, and I shared some examples in the comment: https://github.com/Azure/terraform-provider-azapi/issues/453#issuecomment-2095200485

Please check if it could help in your case.

ms-henglu avatar May 14 '24 06:05 ms-henglu

Thank you for responding, i will be attempting to use your example fixes and return once tested.

emad0082 avatar May 16 '24 08:05 emad0082

Alright

I have now tested the proposed solutions. And i can only get the FQDN rules to work. The privat endpoint outbound rules still returns the same error. This is after i have tested it with version 1.12.1 of the provider and the azapi_resource_action solution.

Currently i have found no solutions to provision private endpoint outbound Rules using Terraform.

@ms-henglu are there any updates to this issue?

emad0082 avatar May 22 '24 11:05 emad0082

@ms-henglu just an update.

We are now experiencing failures when provisioning outbound FQDN rules, which used to work without issues earlier this month. However, our team is experiencing problems when dynamically adding new FQDN rules. We are having the issue on both v1.13.1 and v1.12.1

When can we expect this to be worked on?

emad0082 avatar Jun 10 '24 08:06 emad0082

Hey @emad0082, sorry for the lack of response on this thread. To clarify, are you experiencing issues with new FQDN rules or existing ones?

stemaMSFT avatar Jun 10 '24 17:06 stemaMSFT

Hey @ms-henglu

It seems there was issues on our end regarding the outbound FQDN rules.

The error message returned, "MissingApiVersionParameter," was not relevant to my scenario. The actual issue was a mistake in my code, as I tried to add workspace outbound settings while the workspace was in "disabled" mode. The error message should have indicated this specific problem, though. But i do not expect you guys to put time into such a small issue. I'd much rather the private endpoint outbpund rules problems was fixed.

emad0082 avatar Jun 11 '24 08:06 emad0082