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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for idle shutdown option in azurerm_machine_learning_compute_instance #20973

Open
1 task done
mclacore opened this issue Mar 16, 2023 · 7 comments
Open
1 task done

Comments

@mclacore
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Azure Machine Learning compute instance allows setting an idle shutdown to save on costs:
image

Adding this to the terraform resource would be greatly appreciated.

I realize this is a preview feature for Machine Learning Workspace, but it seems to ship enabled by default.

New or Affected Resource(s)/Data Source(s)

azurerm_machine_learning_compute_instance

Potential Terraform Configuration

resource "azurerm_machine_learning_compute_instance" "example" {
  name                          = "example"
  location                      = azurerm_resource_group.example.location
  machine_learning_workspace_id = azurerm_machine_learning_workspace.example.id
  virtual_machine_size          = "STANDARD_DS2_V2"
  authorization_type            = "personal"
  idle_shutdown_enable          = true
  idle_shutdown_duration        = "PT1H"
  ssh {
    public_key = var.ssh_key
  }
  subnet_resource_id = azurerm_subnet.example.id
  description        = "foo"
  tags = {
    foo = "bar"
  }
}

References

https://learn.microsoft.com/en-us/azure/machine-learning/how-to-create-manage-compute-instance?tabs=python#enable-idle-shutdown-preview

@gesnaud
Copy link

gesnaud commented Nov 16, 2023

Hi community!

I wonder to have this feature a day!

@pavanmuni321
Copy link

Still waiting for this property to be added!! Meanwhile I did a workaround using terraform to call ARM template which has this attribute.

@Uranium2
Copy link

Any updates on this useful feature?

@pavanmuni321 could you share how you did to get the ARM template of an existing Compute Instance? I do not want to use the ARM template of all AML ressource

@ltutar
Copy link

ltutar commented Mar 25, 2024

I also would like to have this option.

@pavanmuni321
Copy link

pavanmuni321 commented May 3, 2024

Any updates on this useful feature?

@pavanmuni321 could you share how you did to get the ARM template of an existing Compute Instance? I do not want to use the ARM template of all AML ressource

Here is the arm template I have used. Please note I have tested other api versions and only "2023-10-01" seems to be working for me!

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "parameterBlock": {
            "type": "Object"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.MachineLearningServices/workspaces/computes",
            "apiVersion": "2023-10-01",
            "name": "[parameters('parameterBlock').lcomputeName]",
            "location": "[parameters('parameterBlock').location]",
            "identity": {
                "type": "[parameters('parameterBlock').managedIdentityType]",
                "userAssignedIdentities": {
                    "[parameters('parameterBlock').userAssignedIdentity_id]": {}
                }
            },
            "properties": {
                "computeLocation": "[parameters('parameterBlock').location]",
                "description": "[parameters('parameterBlock').description]",
                "disableLocalAuth": "true",
                "computeType": "ComputeInstance",
                "properties": {
                    "computeInstanceAuthorizationType": "personal",
                    "enableNodePublicIp": false,
                    "idleTimeBeforeShutdown": "[parameters('parameterBlock').idleTimeBeforeShutdown]",
                    "personalComputeInstanceSettings": {
                        "assignedUser": {
                            "objectId": "[parameters('parameterBlock').objectId]",
                            "tenantId": "[parameters('parameterBlock').tenantId]"
                        }
                    },
                    "subnet": {
                        "id": "[parameters('parameterBlock').subnet_id]"
                    },
                    "vmSize": "[parameters('parameterBlock').vmSize]"
                }
            }
        }
    ]
}

which is deployed using terraform below

# Create Compute Instances in Azure Machine Learning Workspace (using ARM template)
resource "azurerm_resource_group_template_deployment" "ml_compute_instance" {
  name                = "rgt-compute-instance"
  resource_group_name = var.resourceGroupName

  parameters_content = jsonencode({
    parameterBlock = {
      value = {
        name                   = var.computeName
        location               = var.location
        tenantId               = data.azurerm_client_config.current.tenant_id
        objectId               = var.userObjectId
        workspaceName          = var.WorkspaceName
        description            = "Compute Instance Assigned to Single-User"
        vmSize                 = var.cpu_compute_size
        idleTimeBeforeShutdown = var.instance_shutdown_time
        subnet_id              = var.subnetId
        managedIdentityType    = var.managed_identity_type
        userAssignedIdentityId = azurerm_user_assigned_identity.ml_managed_identity.id
      }
    }
  })

  template_content = file("${path.module}/aml-compute.json")
  deployment_mode  = "Incremental"
}

@ltutar
Copy link

ltutar commented May 3, 2024

@Uranium2 If it is for any help, I am using the following to create the compute instance with idle time before shutdown.

resource "azapi_resource" "ci003" {
  name      = "adm-ltutar"
  parent_id = azurerm_machine_learning_workspace.ml_workspace.id
  type      = "Microsoft.MachineLearningServices/workspaces/computes@2023-08-01-preview"
  location  = var.global_settings.location
  identity {
    type = "SystemAssigned"
  }
  body = jsonencode({
    properties = {
      computeType      = "ComputeInstance"
      description      = "This compute instance is created for Levent Tutar"
      disableLocalAuth = true
      properties = {
        vmSize                 = "STANDARD_DS3_v2"
        idleTimeBeforeShutdown = "PT15M"
        enableNodePublicIp     = false
        personalComputeInstanceSettings = {
          assignedUser = {
            objectId = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxx"
            tenantId = var.global_settings.tenant_id
          }
        }
      }
    }
  })
}

with the following global settings:

global_settings = {
  tenant_id       = "xxx-xxx-xxx-xxx-xxxx"
  subscription_id = "xxx-xxx-xxx-xxx-xxx"

  # Deployment variables
  location_short = "weu"
  location       = "westeurope"
  serial_number  = "001"
  app_short      = "ml"
  environment    = "dev" #short like dev,acc,prd
}

@deepaknani007
Copy link

Any updates on adding this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants