This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
role-assignment-using-rest-api.http
94 lines (74 loc) · 3.31 KB
/
role-assignment-using-rest-api.http
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
### Role assignment using REST API
@clientid=xxx
@tenantid=xxx
@clientsecret=xxx
@subscriptionid=xxx
@resourcegroupname=xxx
@workspacename=xxx
@fhirservicename=xxx
@dicomservicename=xxx
@authorityurl=https://login.microsoftonline.com
@azureresource=https://management.azure.com/
#role definition id, not role names
#az role definition list --name "FHIR Data Contributor"
#az role definition list --name "DICOM Data Owner"
@fhirrolename=5a1fc7df-4bf1-4951-a576-89034ee01acd
@dicomrolename=58a3b984-7adf-4c20-983a-32417c86fbc8
@apiversion=2021-06-01-preview
@roleapiversion=2021-04-01-preview
#Get service principal id
@spid=xxx
### Get an access token for management resource
# @name getAzureToken
POST https://login.microsoftonline.com/{{tenantid}}/oauth2/token
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
&resource={{azureresource}}
&client_id={{clientid}}
&client_secret={{clientsecret}}
### Capture access token from getToken request
@token = {{getAzureToken.response.body.access_token}}
#Alternatively, get access token for the current user
#az account get-access-token --resource "https://management.azure.com/"
#Get-AzAccessToken -ResourceUrl "https://management.azure.com/"
#@token=xxx
### Get GUID using Visual Studio or online tools
#GET https://www.uuidgenerator.net/api/guid
### define assignment name
@roleassignmentid=xxx
### Create role assignments
#Grant user access admin role to the user or a dedicated service principal
@scope1=/subscriptions/{{subscriptionid}}/resourceGroups/{{resourcegroupname}}/providers/Microsoft.HealthcareApis/services/{{fhirservicename}}
###Send Put request to assign roles - Azure API for FHIR
PUT https://management.azure.com/{{scope1}}/providers/Microsoft.Authorization/roleAssignments/{{roleassignmentid}}?api-version={{roleapiversion}}
Authorization: Bearer {{token}}
Content-Type: application/json
Accept: application/json
{
"properties": {
"roleDefinitionId": "/subscriptions/{{subscriptionid}}/providers/Microsoft.Authorization/roleDefinitions/{{fhirrolename}}",
"principalId": "{{spid}}"
}
}
###Send Put request to assign roles - Healthcare APIs (DICOM)
@scope2=/subscriptions/{{subscriptionid}}/resourceGroups/{{resourcegroupname}}/providers/Microsoft.HealthcareApis/workspaces/{{workspacename}}/dicomservices/{{dicomservicename}}
PUT https://management.azure.com/{{scope2}}/providers/Microsoft.Authorization/roleAssignments/{{roleassignmentid}}?api-version={{roleapiversion}}
Authorization: Bearer {{token}}
Content-Type: application/json
Accept: application/json
{
"properties": {
"roleDefinitionId": "/subscriptions/{{subscriptionid}}/providers/Microsoft.Authorization/roleDefinitions/{{dicomrolename}}",
"principalId": "{{spid}}"
}
}
### List services - Azure API for FHIR
GET https://management.azure.com/subscriptions/{{subscriptionid}}/providers/Microsoft.HealthcareApis/services?api-version={{apiversion}}
Authorization: Bearer {{token}}
Content-Type: application/json
Accept: application/json
### List services - Healthcare APIs FHIR/DICOM services
GET https://management.azure.com/subscriptions/{{subscriptionid}}/resourceGroups/{{resourcegroupname}}/providers/Microsoft.HealthcareApis/workspaces/{{workspacename}}/dicomservices?api-version={{apiversion}}
Authorization: Bearer {{token}}
Content-Type: application/json
Accept: application/json