forked from Azure/azureml-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the script for adding identity with compute (Azure#2014)
* Refactor the script for adding identity with compute
- Loading branch information
1 parent
9c88c15
commit b6e30f4
Showing
4 changed files
with
31 additions
and
53 deletions.
There are no files selected for viewing
49 changes: 0 additions & 49 deletions
49
.github/workflows/cli-scripts-deploy-mlcompute-create-with-user-identity.yml
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,30 @@ | ||
IDENTITY=$(az identity create -n my-cluster-identity --query id -o tsv) | ||
az ml compute update --name mycluster --identity-type user_assigned --user-assigned-identities $IDENTITY | ||
export MSI_NAME=my-cluster-identity | ||
export COMPUTE_NAME=mycluster-msi | ||
|
||
does_compute_exist() | ||
{ | ||
if [ -z $(az ml compute show -n $COMPUTE_NAME --query name) ]; then | ||
echo false | ||
else | ||
echo true | ||
fi | ||
} | ||
|
||
echo "Creating MSI $MSI_NAME" | ||
# Get the resource id of the identity | ||
IDENTITY_ID=$(az identity show --name "$MSI_NAME" --query id -o tsv | tail -n1 | tr -d "[:cntrl:]" || true) | ||
if [[ -z $IDENTITY_ID ]]; then | ||
IDENTITY_ID=$(az identity create -n "$MSI_NAME" --query id -o tsv | tail -n1 | tr -d "[:cntrl:]") | ||
fi | ||
echo "MSI created: $MSI_NAME" | ||
sleep 15 # Let the previous command finish: https://github.com/Azure/azure-cli/issues/8530 | ||
|
||
|
||
echo "Checking if compute $COMPUTE_NAME already exists" | ||
if [ "$(does_compute_exist)" == "true" ]; then | ||
echo "Skipping, compute: $COMPUTE_NAME exists" | ||
else | ||
echo "Provisioning compute: $COMPUTE_NAME" | ||
az ml compute create --name "$COMPUTE_NAME" --type amlcompute --identity-type user_assigned --user-assigned-identities "$IDENTITY_ID" | ||
fi | ||
az ml compute update --name "$COMPUTE_NAME" --identity-type user_assigned --user-assigned-identities "$IDENTITY_ID" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters