/
LogicApp.yaml
145 lines (145 loc) · 4.58 KB
/
LogicApp.yaml
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
$schema: https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#
contentVersion: 1.0.0.0
parameters:
location:
type: string
metadata:
description: Location of the Logic App.
defaultValue: "[resourceGroup().location]"
logicAppName:
type: string
metadata:
description: Name of the Logic App.
keyVaultApiConnectionName:
type: string
metadata:
description: Name of the API Connector.
keyVaultSecretName:
type: string
metadata:
description: Name of Key Vault secret.
defaultValue: ""
variables:
logicApp:
name: "[parameters('logicAppName')]"
apiVersion: "[providers('Microsoft.Logic', 'workflows').apiVersions[0]]"
location: "[parameters('location')]"
apiConn:
keyvault:
name: "[parameters('keyVaultApiConnectionName')]"
apiVersion: "[providers('Microsoft.Web', 'connections').apiVersions[0]]"
location: "[parameters('location')]"
keyVault:
secret:
name: "[parameters('keyVaultSecretName')]"
tags:
author: Justin Yoo
profile: https://twitter.com/justinchronicle
projectUrl: https://github.com/aliencube/Key-Vault-Connector-for-Logic-Apps
repositoryUrl: https://github.com/aliencube/Key-Vault-Connector-for-Logic-Apps
license: https://raw.githubusercontent.com/aliencube/Key-Vault-Connector-for-Logic-Apps/master/LICENSE
resources:
- comments: "### RESOURCE - LOGIC APP - KEY VAULT CONNECTION SAMPLE ###"
type: Microsoft.Logic/workflows
apiVersion: "[variables('logicApp').apiVersion]"
location: "[variables('logicApp').location]"
name: "[variables('logicApp').name]"
tags: "[variables('tags')]"
identity:
type: SystemAssigned
properties:
parameters:
$connections:
value:
keyvault:
id: "[concat(resourceGroup().id, '/providers/Microsoft.Web/customApis/keyvault')]"
connectionId: "[resourceId('Microsoft.Web/connections', variables('apiConn').keyvault.name)]"
connectionName: "[variables('apiConn').keyvault.name]"
definition:
$schema: https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#
contentVersion: 1.0.0.0
parameters:
$connections:
type: object
defaultValue: {}
keyVault:
type: object
defaultValue: "[variables('keyVault')]"
triggers:
manual:
type: Request
kind: Http
inputs:
schema:
type: object
properties:
secretName:
type: string
actions:
Get_the_List_of_Secrets:
type: ApiConnection
runAfter: {}
inputs:
method: GET
host:
connection:
name: "@parameters('$connections')['keyvault']['connectionId']"
path: /secrets
Initialise_Secret_Name:
type: InitializeVariable
runAfter: {}
inputs:
variables:
- type: string
name: SecretName
value: "@parameters('keyVault')['secret']['name']"
Check_Secret_Name_from_Request:
type: If
runAfter:
Initialise_Secret_Name:
- Succeeded
expression:
and:
- equals:
- "@coalesce(triggerBody()?.secretName, '')"
- ""
actions: {}
else:
actions:
Set_Secret_Name_from_Request:
type: SetVariable
runAfter: {}
inputs:
name: SecretName
value: "@triggerBody()?.secretName"
Get_the_Secret_Details:
type: ApiConnection
runAfter:
Check_Secret_Name_from_Request:
- Succeeded
inputs:
method: GET
host:
connection:
name: "@parameters('$connections')['keyvault']['connectionId']"
path: /secrets/@{encodeURIComponent(variables('SecretName'))}
Response:
type: Response
runAfter:
Get_the_List_of_Secrets:
- Succeeded
- Failed
Get_the_Secret_Details:
- Succeeded
- Failed
inputs:
statusCode: 200
body:
secretName: "@variables('SecretName')"
secrets: "@body('Get_the_List_of_Secrets')"
secret: "@body('Get_the_Secret_Details')"
outputs: {}
outputs:
logicAppName:
type: string
value: "[variables('logicApp').name]"