|
49 | 49 | "metadata": { |
50 | 50 | "metadata": {} |
51 | 51 | }, |
52 | | - "outputs": [], |
| 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 | + ], |
53 | 61 | "source": [ |
54 | 62 | "import os, sys, json, base64, random, string\n", |
55 | 63 | "sys.path.insert(1, '../../shared') # add the shared directory to the Python path\n", |
56 | 64 | "import utils\n", |
57 | 65 | "\n", |
58 | 66 | "deployment_name = os.path.basename(os.path.dirname(globals()['__vsc_ipynb_file__']))\n", |
59 | | - "resource_group_name = f\"lab-{deployment_name}\" # change the name to match your naming style\n", |
| 67 | + "resource_group_name = f\"lab-{deployment_name}-2\" # change the name to match your naming style\n", |
60 | 68 | "resource_group_location = \"ukwest\"\n", |
| 69 | + "resource_suffix = ''.join(random.choices(string.ascii_letters + string.digits, k=8)).lower()\n", |
61 | 70 | "\n", |
62 | 71 | "aiservices_config = []\n", |
63 | 72 | "\n", |
|
71 | 80 | "inference_api_version = \"2025-03-01-preview\"\n", |
72 | 81 | "foundry_project_name = deployment_name\n", |
73 | 82 | "\n", |
74 | | - "app_registration_name = f\"lab-{deployment_name}-app\"\n", |
| 83 | + "app_registration_name = f\"lab-{deployment_name}-{resource_suffix}-app\"\n", |
75 | 84 | "\n", |
76 | 85 | "build = 0\n", |
77 | 86 | "prm_mcp_server_image = \"mcp-prm-server\"\n", |
|
99 | 108 | }, |
100 | 109 | { |
101 | 110 | "cell_type": "code", |
102 | | - "execution_count": null, |
| 111 | + "execution_count": 2, |
103 | 112 | "metadata": {}, |
104 | | - "outputs": [], |
| 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 | 126 | "source": [ |
106 | 127 | "output = utils.run(\"az account show\", \"Retrieved az account\", \"Failed to get the current az account\")\n", |
107 | 128 | "\n", |
|
129 | 150 | "cell_type": "code", |
130 | 151 | "execution_count": null, |
131 | 152 | "metadata": {}, |
132 | | - "outputs": [], |
| 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 | 179 | "source": [ |
134 | 180 | "# Create the resource group if doesn't exist\n", |
135 | 181 | "utils.create_resource_group(resource_group_name, resource_group_location)\n", |
|
141 | 187 | " \"parameters\": {\n", |
142 | 188 | " \"mcpEntraAppName\": { \"value\": app_registration_name },\n", |
143 | 189 | " \"apimSku\": { \"value\": apim_sku },\n", |
| 190 | + " # \"resourceSuffix\": { \"value\": resource_suffix },\n", |
144 | 191 | " \"aiServicesConfig\": { \"value\": aiservices_config },\n", |
145 | 192 | " \"modelsConfig\": { \"value\": models_config },\n", |
146 | 193 | " \"apimSubscriptionsConfig\": { \"value\": apim_subscriptions_config },\n", |
|
175 | 222 | }, |
176 | 223 | { |
177 | 224 | "cell_type": "code", |
178 | | - "execution_count": null, |
| 225 | + "execution_count": 4, |
179 | 226 | "metadata": {}, |
180 | | - "outputs": [], |
| 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 | 255 | "source": [ |
182 | 256 | "# Obtain all of the outputs from the deployment\n", |
183 | 257 | "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