|
49 | 49 | "metadata": { |
50 | 50 | "metadata": {} |
51 | 51 | }, |
52 | | - "outputs": [ |
53 | | - { |
54 | | - "name": "stdout", |
55 | | - "output_type": "stream", |
56 | | - "text": [ |
57 | | - "✅ \u001b[1;32mNotebook initialized\u001b[0m ⌚ 17:41:29.961075 \n" |
58 | | - ] |
59 | | - } |
60 | | - ], |
| 52 | + "outputs": [], |
61 | 53 | "source": [ |
62 | 54 | "import os, sys, json, base64, random, string\n", |
63 | 55 | "sys.path.insert(1, '../../shared') # add the shared directory to the Python path\n", |
64 | 56 | "import utils\n", |
65 | 57 | "\n", |
66 | 58 | "deployment_name = os.path.basename(os.path.dirname(globals()['__vsc_ipynb_file__']))\n", |
67 | | - "resource_group_name = f\"lab-{deployment_name}-2\" # change the name to match your naming style\n", |
| 59 | + "resource_group_name = f\"lab-{deployment_name}-4\" # change the name to match your naming style\n", |
68 | 60 | "resource_group_location = \"ukwest\"\n", |
69 | 61 | "resource_suffix = ''.join(random.choices(string.ascii_letters + string.digits, k=8)).lower()\n", |
70 | 62 | "\n", |
|
108 | 100 | }, |
109 | 101 | { |
110 | 102 | "cell_type": "code", |
111 | | - "execution_count": 2, |
| 103 | + "execution_count": null, |
112 | 104 | "metadata": {}, |
113 | | - "outputs": [ |
114 | | - { |
115 | | - "name": "stdout", |
116 | | - "output_type": "stream", |
117 | | - "text": [ |
118 | | - "⚙️ \u001b[1;34mRunning: az account show \u001b[0m\n", |
119 | | - "✅ \u001b[1;32mRetrieved az account\u001b[0m ⌚ 17:41:34.969378 [0m:4s]\n", |
120 | | - "👉🏽 \u001b[1;34mCurrent user: admin@MngEnvMCAP597089.onmicrosoft.com\u001b[0m\n", |
121 | | - "👉🏽 \u001b[1;34mTenant ID: cef7fc0f-a52f-4e91-8198-e00530d523b6\u001b[0m\n", |
122 | | - "👉🏽 \u001b[1;34mSubscription ID: c15de093-adb5-498b-beda-73764e08f7a9\u001b[0m\n" |
123 | | - ] |
124 | | - } |
125 | | - ], |
| 105 | + "outputs": [], |
126 | 106 | "source": [ |
127 | 107 | "output = utils.run(\"az account show\", \"Retrieved az account\", \"Failed to get the current az account\")\n", |
128 | 108 | "\n", |
|
150 | 130 | "cell_type": "code", |
151 | 131 | "execution_count": null, |
152 | 132 | "metadata": {}, |
153 | | - "outputs": [ |
154 | | - { |
155 | | - "name": "stdout", |
156 | | - "output_type": "stream", |
157 | | - "text": [ |
158 | | - "⚙️ \u001b[1;34mRunning: az group show --name lab-mcp-prm-oauth \u001b[0m\n", |
159 | | - "👉🏽 \u001b[1;34mUsing existing resource group 'lab-mcp-prm-oauth'\u001b[0m\n", |
160 | | - "⚙️ \u001b[1;34mRunning: az deployment group create --name mcp-prm-oauth --resource-group lab-mcp-prm-oauth --template-file main.bicep --parameters params.json \u001b[0m\n", |
161 | | - "❌ \u001b[1;33mDeployment 'mcp-prm-oauth' failed\u001b[0m ⌚ 17:45:31.396062 [3m:47s] WARNING: A new Bicep release is available: v0.45.15. Upgrade now by running \"az bicep upgrade\".\n", |
162 | | - "WARNING: /workspaces/AI-Gateway/labs/mcp-prm-oauth/src/bicep/apim-mcp/mcp-api.bicep(96,5) : Warning BCP037: The property \"backendId\" is not allowed on objects of type \"ApiCreateOrUpdatePropertiesOrApiContractProperties\". Permissible properties include \"apiRevision\", \"apiRevisionDescription\", \"apiType\", \"apiVersion\", \"apiVersionDescription\", \"apiVersionSet\", \"apiVersionSetId\", \"contact\", \"format\", \"license\", \"serviceUrl\", \"sourceApiId\", \"subscriptionKeyParameterNames\", \"termsOfServiceUrl\", \"translateRequiredQueryParameters\", \"value\", \"wsdlSelector\". If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues. [https://aka.ms/bicep/core-diagnostics#BCP037]\n", |
163 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/src/bicep/apim-mcp/mcp-api.bicep(101,19) : Warning BCP036: The property \"endpoints\" expected a value of type \"McpEndpoint[] | null\" but the provided value is of type \"object\". If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues. [https://aka.ms/bicep/core-diagnostics#BCP036]\n", |
164 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(5,7) : Warning no-unused-params: Parameter \"aiServicesConfig\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n", |
165 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(6,7) : Warning no-unused-params: Parameter \"modelsConfig\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n", |
166 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(9,7) : Warning no-unused-params: Parameter \"inferenceAPIType\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n", |
167 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(10,7) : Warning no-unused-params: Parameter \"inferenceAPIPath\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n", |
168 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(11,7) : Warning no-unused-params: Parameter \"foundryProjectName\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n", |
169 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(15,7) : Warning no-unused-params: Parameter \"encryptionIV\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n", |
170 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(19,7) : Warning no-unused-params: Parameter \"encryptionKey\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n", |
171 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(22,7) : Warning no-unused-params: Parameter \"oauthScopes\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n", |
172 | | - "/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(103,9) : Warning BCP334: The provided value can have a length as small as 3 and may be too short to assign to a target with a configured minimum length of 5. [https://aka.ms/bicep/core-diagnostics#BCP334]\n", |
173 | | - "\n", |
174 | | - "ERROR: {\"status\":\"Failed\",\"error\":{\"code\":\"DeploymentFailed\",\"target\":\"/subscriptions/c15de093-adb5-498b-beda-73764e08f7a9/resourceGroups/lab-mcp-prm-oauth/providers/Microsoft.Resources/deployments/mcp-prm-oauth\",\"message\":\"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.\",\"details\":[{\"code\":\"ResourceDeploymentFailure\",\"target\":\"/subscriptions/c15de093-adb5-498b-beda-73764e08f7a9/resourceGroups/lab-mcp-prm-oauth/providers/Microsoft.Resources/deployments/apimModule\",\"message\":\"The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'.\",\"details\":[{\"code\":\"DeploymentFailed\",\"target\":\"/subscriptions/c15de093-adb5-498b-beda-73764e08f7a9/resourceGroups/lab-mcp-prm-oauth/providers/Microsoft.Resources/deployments/apimModule\",\"message\":\"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.\",\"details\":[{\"code\":\"ServiceAlreadyExistsInSoftDeletedState\",\"message\":\"Api service apim-zarnuffqegamc was soft-deleted. In order to create the new service with the same name, you have to either undelete the service or purge it. See https://aka.ms/apimsoftdelete.\"}]}]}]}}\n", |
175 | | - "\n" |
176 | | - ] |
177 | | - } |
178 | | - ], |
| 133 | + "outputs": [], |
179 | 134 | "source": [ |
180 | 135 | "# Create the resource group if doesn't exist\n", |
181 | 136 | "utils.create_resource_group(resource_group_name, resource_group_location)\n", |
|
187 | 142 | " \"parameters\": {\n", |
188 | 143 | " \"mcpEntraAppName\": { \"value\": app_registration_name },\n", |
189 | 144 | " \"apimSku\": { \"value\": apim_sku },\n", |
190 | | - " # \"resourceSuffix\": { \"value\": resource_suffix },\n", |
191 | 145 | " \"aiServicesConfig\": { \"value\": aiservices_config },\n", |
192 | 146 | " \"modelsConfig\": { \"value\": models_config },\n", |
193 | 147 | " \"apimSubscriptionsConfig\": { \"value\": apim_subscriptions_config },\n", |
|
222 | 176 | }, |
223 | 177 | { |
224 | 178 | "cell_type": "code", |
225 | | - "execution_count": 4, |
| 179 | + "execution_count": null, |
226 | 180 | "metadata": {}, |
227 | | - "outputs": [ |
228 | | - { |
229 | | - "name": "stdout", |
230 | | - "output_type": "stream", |
231 | | - "text": [ |
232 | | - "⚙️ \u001b[1;34mRunning: az deployment group show --name mcp-prm-oauth -g lab-mcp-prm-oauth \u001b[0m\n", |
233 | | - "✅ \u001b[1;32mRetrieved deployment: mcp-prm-oauth\u001b[0m ⌚ 17:45:39.954978 [0m:8s]\n", |
234 | | - "❌ \u001b[1;33mFailed to retrieve output property: 'logAnalyticsWorkspaceId'\n", |
235 | | - "Error: 'NoneType' object is not subscriptable\u001b[0m ⌚ 17:45:39.955559 \n" |
236 | | - ] |
237 | | - }, |
238 | | - { |
239 | | - "ename": "Exception", |
240 | | - "evalue": "Failed to retrieve output property: 'logAnalyticsWorkspaceId'\nError: 'NoneType' object is not subscriptable", |
241 | | - "output_type": "error", |
242 | | - "traceback": [ |
243 | | - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", |
244 | | - "\u001b[31mTypeError\u001b[39m Traceback (most recent call last)", |
245 | | - "\u001b[36mFile \u001b[39m\u001b[32m/workspaces/AI-Gateway/labs/mcp-prm-oauth/../../shared/utils.py:197\u001b[39m, in \u001b[36mget_deployment_output\u001b[39m\u001b[34m(output, output_property, output_label, secure)\u001b[39m\n\u001b[32m 196\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m197\u001b[39m deployment_output = \u001b[30;43moutput\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43mjson_data\u001b[39;49m\u001b[30;43m[\u001b[39;49m\u001b[30;43m'\u001b[39;49m\u001b[30;43mproperties\u001b[39;49m\u001b[30;43m'\u001b[39;49m\u001b[30;43m]\u001b[39;49m\u001b[30;43m[\u001b[39;49m\u001b[30;43m'\u001b[39;49m\u001b[30;43moutputs\u001b[39;49m\u001b[30;43m'\u001b[39;49m\u001b[30;43m]\u001b[39;49m\u001b[30;43m[\u001b[39;49m\u001b[30;43moutput_property\u001b[39;49m\u001b[30;43m]\u001b[39;49m[\u001b[33m'\u001b[39m\u001b[33mvalue\u001b[39m\u001b[33m'\u001b[39m]\n\u001b[32m 199\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m output_label:\n", |
246 | | - "\u001b[31mTypeError\u001b[39m: 'NoneType' object is not subscriptable", |
247 | | - "\nDuring handling of the above exception, another exception occurred:\n", |
248 | | - "\u001b[31mException\u001b[39m Traceback (most recent call last)", |
249 | | - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 2\u001b[39m output = utils.run(f\"az deployment group show --name {deployment_name} -g {resource_group_name}\", f\"Retrieved deployment: {deployment_name}\", f\"Failed to retrieve deployment: {deployment_name}\")\n\u001b[32m 3\u001b[39m \n\u001b[32m 4\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m output.success \u001b[38;5;28;01mand\u001b[39;00m output.json_data:\n\u001b[32m 5\u001b[39m \u001b[38;5;66;03m# Monitoring\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m log_analytics_id = utils.get_deployment_output(output, \u001b[33m'logAnalyticsWorkspaceId'\u001b[39m, \u001b[33m'Log Analytics Id'\u001b[39m)\n\u001b[32m 7\u001b[39m app_insights_name = utils.get_deployment_output(output, \u001b[33m'applicationInsightsName'\u001b[39m, \u001b[33m'Application Insights Name'\u001b[39m)\n\u001b[32m 8\u001b[39m app_insights_app_id = utils.get_deployment_output(output, \u001b[33m'applicationInsightsAppId'\u001b[39m, \u001b[33m'Application Insights App Id'\u001b[39m)\n\u001b[32m 9\u001b[39m \n", |
250 | | - "\u001b[36mFile \u001b[39m\u001b[32m/workspaces/AI-Gateway/labs/mcp-prm-oauth/../../shared/utils.py:209\u001b[39m, in \u001b[36mget_deployment_output\u001b[39m\u001b[34m(output, output_property, output_label, secure)\u001b[39m\n\u001b[32m 207\u001b[39m error = \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mFailed to retrieve output property: \u001b[39m\u001b[33m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00moutput_property\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33mError: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 208\u001b[39m print_error(error)\n\u001b[32m--> \u001b[39m\u001b[32m209\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m(error)\n", |
251 | | - "\u001b[31mException\u001b[39m: Failed to retrieve output property: 'logAnalyticsWorkspaceId'\nError: 'NoneType' object is not subscriptable" |
252 | | - ] |
253 | | - } |
254 | | - ], |
| 181 | + "outputs": [], |
255 | 182 | "source": [ |
256 | 183 | "# Obtain all of the outputs from the deployment\n", |
257 | 184 | "output = utils.run(f\"az deployment group show --name {deployment_name} -g {resource_group_name}\", f\"Retrieved deployment: {deployment_name}\", f\"Failed to retrieve deployment: {deployment_name}\")\n", |
|
0 commit comments