Azure Machine Learning Clemens Siebler  

Enforcing Init Scripts on Azure Machine Learning Compute Instances

This post is a quick tip, showing how you can automatically enforce an Init Script during Azure Machine Learning Compute Instance provisioning. This ensures that even when the user did not specify a script, a default script is always being executed.

For more details on the init script capabilities, have a look at the documentation.

Instructions

Firstly, create your desired init script – in our example, we’ll just use a simple example:

#!/bin/bash

echo "Hello World"

Then base64-encode the script and replace the value in line 26 with your encoded script:

Next, create a new Policy definition in Azure Policy:

You’ll need to define in which subscription the definition should live in, give it a name and a description and then finally paste the policy JSON into the Policy Rule. Then hit Save.

Now that we have a Policy, we can create an assignment. This will apply the policy to Azure resources. Inside Azure Policy, navigate to Assignments and select Assign policy.

Then define the scope of the assignment (which subscriptions it should affect), select our Policy definition and hit Create.

That’s it, our policy is live!

Making sure it works

Lastly, go to Azure Machine Learning Studio and provision a new Compute Instance without selecting an init script. Once the instance has been provisioned, open the instance details and you should see the stdout under the Logs tab.

Hope this helps!

Happy instance creating!

Leave A Comment