microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
32bcffe86a3647ddd45528ecb551f8feddd749ab

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/vscode/src/azure/test/REST API tests.http

141lines · modecode

1// For use with the "REST Client" VS Code extension https://github.com/Huachao/vscode-restclient
2// to test the Azure management and Quantum REST API.
3
4@ARM_EP = management.azure.com
5
6// Set the following either in settings.json, or as variables in this file.
7// See https://github.com/Huachao/vscode-restclient#environment-variables
8// Note: To get the auth tokens, it's easiest to set breakpoints in the VS Code extension and grab them from there.
9// The tokens and the SAS URI are only valid for a short time, so you'll need to get new ones each time you run this.
10//
11// @ARM_AAD_TOKEN = eyJ0eXAiOi...
12// @QUANTUM_TOKEN = eyJhbGciOi...
13// @QUANTUM_KEY = Xy..uA
14// @BLOB_SASPARAMS = sv=2019-07-07&sig=5vxLvO...
15// @QUANTUM_SUBID = 916dfd6d-030c-...
16// @QUANTUM_RG = MyAzResourceGroup
17// @QUANTUM_WORKSPACE = MyWorkspace
18// @QUANTUM_ENDPOINT = westus2.quantum.azure.com
19// @BLOB_ENDPOINT = storageaccountname.blob.core.windows.net
20// @BLOB_CONTAINER = job-b639b6e7-...
21
22### Get the tenants for a user
23
24// Use an AAD or MSA token here that should have scope 'https://management.azure.com/user_impersonation'
25
26GET https://{{ARM_EP}}/tenants?api-version=2020-01-01
27Authorization: Bearer {{ARM_AAD_TOKEN}}
28Content-type: application/json
29
30### Request all subscriptions for a user
31
32// Need to use an AAD token for here on (not MSA). This should have 'https://management.azure.com/user_impersonation' scope.
33// If prior request was done with an MSA account/token, need to get an AAD token for the tenant of the subscription.
34
35GET https://{{ARM_EP}}/subscriptions?api-version=2020-01-01
36Authorization: Bearer {{ARM_AAD_TOKEN}}
37Content-type: application/json
38
39### Get all Quantum workspaces for a subscription
40
41GET https://{{ARM_EP}}/subscriptions/{{QUANTUM_SUBID}}/providers/Microsoft.Quantum/workspaces?api-version=2022-01-10-preview
42Authorization: Bearer {{ARM_AAD_TOKEN}}
43Content-type: application/json
44
45### Get the quotas for a workspace
46
47// Note change of endpoint and token from here on. This should be for the account used above, but have the 'https://quantum.microsoft.com/user_impersonation' scope.
48
49GET https://{{QUANTUM_ENDPOINT}}/subscriptions/{{QUANTUM_SUBID}}/resourceGroups/{{QUANTUM_RG}}/providers/Microsoft.Quantum/Workspaces/{{QUANTUM_WORKSPACE}}/quotas?api-version=2022-09-12-preview
50Authorization: Bearer {{QUANTUM_TOKEN}}
51Content-type: application/json
52
53### Provider status
54GET https://{{QUANTUM_ENDPOINT}}/subscriptions/{{QUANTUM_SUBID}}/resourceGroups/{{QUANTUM_RG}}/providers/Microsoft.Quantum/Workspaces/{{QUANTUM_WORKSPACE}}/providerStatus?api-version=2022-09-12-preview
55Authorization: Bearer {{QUANTUM_TOKEN}}
56Content-type: application/json
57
58### Provider status via API key
59GET https://{{QUANTUM_ENDPOINT}}/subscriptions/{{QUANTUM_SUBID}}/resourceGroups/{{QUANTUM_RG}}/providers/Microsoft.Quantum/Workspaces/{{QUANTUM_WORKSPACE}}/providerStatus?api-version=2022-09-12-preview
60x-ms-quantum-api-key: {{QUANTUM_KEY}}
61Content-type: application/json
62
63### Get jobs for the workspace
64GET https://{{QUANTUM_ENDPOINT}}/subscriptions/{{QUANTUM_SUBID}}/resourceGroups/{{QUANTUM_RG}}/providers/Microsoft.Quantum/Workspaces/{{QUANTUM_WORKSPACE}}/jobs?api-version=2022-09-12-preview
65Authorization: Bearer {{QUANTUM_TOKEN}}
66Content-type: application/json
67
68### Get a container sasURI
69
70POST https://{{QUANTUM_ENDPOINT}}/subscriptions/{{QUANTUM_SUBID}}/resourceGroups/{{QUANTUM_RG}}/providers/Microsoft.Quantum/Workspaces/{{QUANTUM_WORKSPACE}}/storage/sasUri?api-version=2022-09-12-preview
71Accept: application/json
72Content-Type: application/json
73Authorization: Bearer {{QUANTUM_TOKEN}}
74
75{"containerName": "{{BLOB_CONTAINER}}"}
76
77
78// === Working with blob storage ===
79// *** TODO: The following requests should be using the quantum service proxy now, not going direct to storage.
80
81// From here on, the requests are to blob storage, not the quantum endpoint.
82
83// Currently you need to PUT the job file, and GET results, directly from Azure Blob storage.
84// You query the quantum endpoint to get SAS URIs to access the blob storage.
85
86// To submit a job
87// - Get a blob storage SAS URI from the quantum endpoint via a POST with the container name in the body
88// - PUT on the blob storage SAS URI to create the container
89// - [optional?] Check via a GET that it was created
90// - PUT the job file directly into the blob storage container
91// - PUT on the quantum endpoint the job data to submit the job
92// - GET the job status from the quantum endpoint until it is complete (Succeeded, Failed, or Cancelled)
93// - GET the job output data from the blob storage container.
94
95// To just get the output data
96// - Get a blob storage SAS URI from the quantum endpoint via a POST with the container name in the body
97// - GET the output data from the blob storage container
98
99
100# Below are requests to blob storage for the job file and output data.
101
102// SAS URI fields (see https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas):
103// - "sv=2019-07-07" is the API version (signed version)
104// - "srt=co" means access to container and objects (signed resource types)
105// - "sp=racw" means read, add, create, write (signed permissions)
106// - "ss=b" means access to blob storage (signed services)
107// - "se=2023-07-28T17:25:07Z" is the expiry date (signed expiry)
108// - "sig=..." is the signature
109
110### Cors check (note that x-ms-* headers must be enabled on the storage account)
111OPTIONS https://{{BLOB_ENDPOINT}}/{{BLOB_CONTAINER}}/outputData?{{BLOB_SASPARAMS}}
112Access-Control-Request-Method: GET
113Host: swernlitest.blob.core.windows.net
114Origin: vscode-file://vscode-app
115Accept: */*
116Accept-Encoding: gzip, deflate, br
117Accept-Language: en-US
118Access-Control-Request-Headers: x-ms-date,x-ms-version
119Cache-Control: no-cache
120Connection: keep-alive
121Pragma: no-cache
122Sec-Fetch-Dest: empty
123Sec-Fetch-Mode: cors
124Sec-Fetch-Site: cross-site
125User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 13_5_0) AppleWebKit/537.36 (KHTML, like Gecko) Code/1.81.1 Chrome/108.0.5359.215 Electron/22.3.18 Safari/537.36
126
127
128### Container properties (not that useful)
129GET https://{{BLOB_ENDPOINT}}/{{BLOB_CONTAINER}}?restype=container&{{BLOB_SASPARAMS}}
130x-ms-version: 2023-01-03
131x-ms-date: {{$datetime rfc1123}}
132
133### Input data (QIR)
134GET https://{{BLOB_ENDPOINT}}/{{BLOB_CONTAINER}}/inputData?{{BLOB_SASPARAMS}}
135x-ms-version: 2023-01-03
136x-ms-date: {{$datetime rfc1123}}
137
138### Output data (histogram)
139GET https://{{BLOB_ENDPOINT}}/{{BLOB_CONTAINER}}/outputData?{{BLOB_SASPARAMS}}
140x-ms-version: 2023-01-03
141x-ms-date: {{$datetime rfc1123}}
142