|
29 | 29 | "azure_maps_url = 'https://atlas.microsoft.com' # OPTIONAL: ENTER THE AZURE MAPS URL IF DIFFERENT FROM DEFAULT\n", |
30 | 30 | "\n", |
31 | 31 | "# 2) Service-defined parameters (please do not change these)\n", |
32 | | - "rg_name = utils.get_infra_rg_name(deployment, index)\n", |
33 | | - "supported_infrastructures = [INFRASTRUCTURE.SIMPLE_APIM, INFRASTRUCTURE.AFD_APIM_PE, INFRASTRUCTURE.APIM_ACA] # ENTER SUPPORTED INFRASTRUCTURES HERE, e.g., [INFRASTRUCTURE.AFD_APIM_PE, INFRASTRUCTURE.AFD_APIM_FE]\n", |
34 | | - "utils.validate_infrastructure(deployment, supported_infrastructures)\n", |
| 32 | + "rg_name = utils.get_infra_rg_name(deployment, index)\n", |
35 | 33 | "sample_folder = \"azure-maps\"\n", |
| 34 | + "nb_helper = utils.NotebookHelper(sample_folder, rg_name, rg_location, deployment, [INFRASTRUCTURE.AFD_APIM_PE, INFRASTRUCTURE.APIM_ACA, INFRASTRUCTURE.SIMPLE_APIM])\n", |
| 35 | + "\n", |
36 | 36 | "# 3) Define the APIs and their operations and policies\n", |
37 | 37 | "\n", |
38 | 38 | "# Policies\n", |
|
48 | 48 | "api1 = API('map-api', 'Map API', '/map', 'This is the proxy for Azure Maps', operations=[mapApi_v2_default_get, mapApi_v1_async_post,mapApi_v2_geocode_get], tags = tags, serviceUrl=azure_maps_url)\n", |
49 | 49 | "\n", |
50 | 50 | "# APIs Array\n", |
51 | | - "# apis: List[API] = [api1, apin]\n", |
52 | 51 | "apis: List[API] = [api1]\n", |
53 | 52 | "\n", |
54 | 53 | "# 4) Set up the named values, for this specific sample, we are using some of the named values in the API policies defined above that can't be known at this point in the process. For those named values, we are setting them in the main.bicep file.\n", |
|
82 | 81 | " 'namedValues': {'value': [nv.to_dict() for nv in nvs]}\n", |
83 | 82 | "}\n", |
84 | 83 | "\n", |
85 | | - "# 2) Infrastructure must be in place before samples can be layered on top\n", |
86 | | - "if not utils.does_resource_group_exist(rg_name):\n", |
87 | | - " utils.print_error(f'The specified infrastructure resource group and its resources must exist first. Please check that the user-defined parameters above are correctly referencing an existing infrastructure. If it does not yet exist, run the desired infrastructure in the /infra/ folder first.')\n", |
88 | | - " raise SystemExit(1)\n", |
89 | | - "\n", |
90 | | - "# 3) Run the deployment\n", |
91 | | - "output = utils.create_bicep_deployment_group_for_sample(sample_folder, rg_name, rg_location, bicep_parameters)\n", |
| 84 | + "# 2) Deploy the bicep template\n", |
| 85 | + "output = nb_helper.deploy_bicep(bicep_parameters)\n", |
92 | 86 | "\n", |
93 | | - "# 4) Print a deployment summary, if successful; otherwise, exit with an error\n", |
94 | | - "if not output.success:\n", |
95 | | - " raise SystemExit('Deployment failed')\n", |
96 | | - "\n", |
97 | | - "if output.success and output.json_data:\n", |
| 87 | + "if output.json_data:\n", |
| 88 | + " apim_name = output.get('apimServiceName', 'APIM Service Name')\n", |
98 | 89 | " apim_gateway_url = output.get('apimResourceGatewayURL', 'APIM API Gateway URL')\n", |
99 | 90 | "\n", |
100 | 91 | "utils.print_ok('Deployment completed')" |
|
122 | 113 | "from apimrequests import ApimRequests\n", |
123 | 114 | "import json\n", |
124 | 115 | "\n", |
125 | | - "tests = ApimTesting(\"AuthX-Pro Sample Tests\")\n", |
| 116 | + "tests = ApimTesting(\"AuthX-Pro Sample Tests\", sample_folder, deployment)\n", |
126 | 117 | "reqs = ApimRequests(apim_gateway_url)\n", |
127 | 118 | "\n", |
128 | 119 | "# 1) Issue a direct request to API Management\n", |
|
145 | 136 | " {\"query\": \"?query=Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France&limit=1\"}\n", |
146 | 137 | " ]\n", |
147 | 138 | "}, msg = 'Calling Async Geocode Batch v1 API with Share Key Auth. Expect initial 202, then a 200 on the polling response', timeout=120, poll_interval=3)\n", |
| 139 | + "\n", |
148 | 140 | "# confirm the response contains \"summary\": { \"successfulRequests\": 5, \"totalRequests\": 5}\n", |
149 | 141 | "tests.verify('summary' in output and 'successfulRequests' in output and json.loads(output)['summary']['successfulRequests'] == 5, True)\n", |
150 | 142 | "\n", |
|
156 | 148 | ], |
157 | 149 | "metadata": { |
158 | 150 | "kernelspec": { |
159 | | - "display_name": ".venv", |
| 151 | + "display_name": "APIM Samples Python 3.12", |
160 | 152 | "language": "python", |
161 | | - "name": "python3" |
| 153 | + "name": "apim-samples" |
162 | 154 | }, |
163 | 155 | "language_info": { |
164 | 156 | "codemirror_mode": { |
|
170 | 162 | "name": "python", |
171 | 163 | "nbconvert_exporter": "python", |
172 | 164 | "pygments_lexer": "ipython3", |
173 | | - "version": "3.12.11" |
| 165 | + "version": "3.12.10" |
174 | 166 | } |
175 | 167 | }, |
176 | 168 | "nbformat": 4, |
|
0 commit comments