Skip to content

Commit 1e240d0

Browse files
authored
Note on how to query os version and define policy
1 parent aee5a30 commit 1e240d0

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

articles/machine-learning/how-to-create-manage-compute-instance.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,71 @@ To create a compute instance, you'll need permissions for the following actions:
673673
* *Microsoft.MachineLearningServices/workspaces/computes/write*
674674
* *Microsoft.MachineLearningServices/workspaces/checkComputeNameAvailability/action*
675675
676+
### Audit and observe compute instance version (preview)
677+
678+
# [Python SDK](#tab/python)
679+
680+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
681+
682+
```python
683+
from azure.ai.ml.entities import ComputeInstance, AmlCompute
684+
685+
# Display operating system version
686+
instance = ml_client.compute.get("myci")
687+
print instance.os_image_metadata
688+
```
689+
690+
For more information on the classes, methods, and parameters used in this example, see the following reference documents:
691+
692+
* [`AmlCompute` class](/python/api/azure-ai-ml/azure.ai.ml.entities.amlcompute)
693+
* [`ComputeInstance` class](/python/api/azure-ai-ml/azure.ai.ml.entities.computeinstance)
694+
695+
# [Azure CLI](#tab/azure-cli)
696+
697+
[!INCLUDE [cli v2](../../includes/machine-learning-cli-v2.md)]
698+
699+
```azurecli
700+
az ml compute show --name "myci"
701+
```
702+
703+
# [Studio](#tab/azure-studio)
704+
705+
In your workspace in Azure Machine Learning studio, select Compute, then select compute instance on the top. Select a compute instance's compute name to see its properties including the current operating system. When a more recent instance OS version is, use the creation wizard to create a new instance.
706+
707+
---
708+
709+
Administrators can use [Azure Policy](./../governance/policy/overview.md) definitions to audit instances that are running on outdated operating system versions. The following is a sample policy:
710+
711+
```json
712+
{
713+
"mode": "All",
714+
"policyRule": {
715+
"if": {
716+
"allOf": [
717+
{
718+
"field": "type",
719+
"equals": "Microsoft.MachineLearningServices/workspaces/computes"
720+
},
721+
{
722+
"field": "Microsoft.MachineLearningServices/workspaces/computes/computeType",
723+
"equals": "ComputeInstance"
724+
},
725+
{
726+
"field": "Microsoft.MachineLearningServices/workspaces/computes/osImageMetadata.isLatestOsImageVersion",
727+
"equals": "false"
728+
}
729+
]
730+
},
731+
"then": {
732+
"effect": "Audit"
733+
}
734+
}
735+
}
736+
```
737+
676738
## Next steps
677739

678740
* [Access the compute instance terminal](how-to-access-terminal.md)
679741
* [Create and manage files](how-to-manage-files.md)
680742
* [Update the compute instance to the latest VM image](concept-vulnerability-management.md#compute-instance)
681-
* [Submit a training job](v1/how-to-set-up-training-targets.md)
743+
* [Submit a training job](v1/how-to-set-up-training-targets.md)

0 commit comments

Comments
 (0)