Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Merge pull request #89 from microsoft/mabou/patch-sub-id
Browse files Browse the repository at this point in the history
Allow both human-friendly subscription name and machine-enabled subsc…
  • Loading branch information
marabout2015 authored Dec 6, 2019
2 parents 1a15dd7 + 835fb4f commit 714679c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
33 changes: 28 additions & 5 deletions 03_Run_Locally.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"metadata": {},
"source": [
"## Azure subscription <a id='subscription'></a>\n",
"If you have multiple subscriptions select the subscription you want to use. If you want to run this in a different location that supports HyperDrive, you may the one you want to use. You can also set the name of the resource group in which this tutorial will add resources. *IMPORTANT NOTE:* The last notebook in this example will delete this resource group and all associated resources."
"If you have multiple subscriptions select the subscription you want to use. You may supply either the subscription's name or the subscription's ID. If you want to run this in a different location that supports HyperDrive, you may enter the one you want to use. You can also set the name of the resource group in which this tutorial will add resources. *IMPORTANT NOTE:* The last notebook in this example will delete this resource group and all associated resources."
]
},
{
Expand All @@ -52,11 +52,33 @@
},
"outputs": [],
"source": [
"selected_subscription=\"YOUR_SUBSCRIPTION\"\n",
"subscription_name=\"YOUR_SUBSCRIPTION_NAME\"\n",
"subscription_id=\"YOUR_SUBSCRIPTION_ID\"\n",
"location=\"eastus\"\n",
"resource_group=\"hypetuning\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check that we have either a subscription name or ID. If the ID has been supplied, then use that value."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"if (subscription_name == \"YOUR_SUBSCRIPTION_NAME\"\n",
" and subscription_id == \"YOUR_SUBSCRIPTION_ID\"):\n",
" raise Exception(\"At least one of a subscription's name or ID must be supplied\")\n",
"if subscription_id != \"YOUR_SUBSCRIPTION_ID\":\n",
" print(\"A subscription ID has been supplied, so it will be used\")\n",
" subscription_name = subscription_id"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -92,7 +114,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%bash -s \"$selected_subscription\"\n",
"%%bash -s \"$subscription_name\"\n",
"az account set --subscription \"$1\"\n",
"az account show -o table"
]
Expand All @@ -101,7 +123,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Get the information for the selected Azure subscription."
"Get the ID for the selected Azure subscription."
]
},
{
Expand All @@ -111,7 +133,8 @@
"outputs": [],
"source": [
"az_profile = get_cli_profile()\n",
"subscription_id = az_profile.get_subscription_id()"
"subscription_id = az_profile.get_subscription_id()\n",
"print(\"Using subscription ID\", subscription_id)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
source /usr/share/miniconda/etc/profile.d/conda.sh
conda activate MLHyperparameterTuning
echo Executing 03_Run_Locally.ipynb
papermill 03_Run_Locally.ipynb 03_Run_Locally_Output.ipynb --log-output --no-progress-bar -k python3 -p selected_subscription $(subscriptionid) -p resource_group $(azurergname)
papermill 03_Run_Locally.ipynb 03_Run_Locally_Output.ipynb --log-output --no-progress-bar -k python3 -p subscription_id $(subscriptionid) -p resource_group $(azurergname)
displayName: '03_Run_Locally.ipynb'
- bash: |
Expand Down

0 comments on commit 714679c

Please sign in to comment.