Allow both human-friendly subscription name and machine-enabled subscription ID
This commit is contained in:
Родитель
778724418f
Коммит
cbce8e2a1f
|
@ -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."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -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": {},
|
||||
|
@ -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"
|
||||
]
|
||||
|
@ -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."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче