Permalink
Cannot retrieve contributors at this time
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up
Fetching contributors…

{ | |
"state": "{{LogicAppState}}", | |
"parameters": { | |
"$connections": { | |
"value": { | |
"azureblob": { | |
"id": "{{AzureBlobApiId}}", | |
"connectionId": "{{AzureBlobApiConnectionId}}", | |
"connectionName": "{{AzureBlobApiConnectionName}}" | |
} | |
} | |
}, | |
"keyVault": { | |
"value": { | |
"baseUrl": "{{KeyVaultBaseUrl}}", | |
"apiVersion": "{{KeyVaultApiVersion}}", | |
"audienceUrl": "{{KeyVaultAudienceUrl}}" | |
} | |
}, | |
"azureBlob": { | |
"value": { | |
"containerName": "{{AzureBlobContainerName}}" | |
} | |
} | |
}, | |
"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": {} | |
}, | |
"azureBlob": { | |
"type": "object", | |
"defaultValue": {} | |
} | |
}, | |
"triggers": { | |
"manual": { | |
"type": "Request", | |
"kind": "Http", | |
"inputs": { | |
"method": "POST", | |
"schema": {} | |
} | |
} | |
}, | |
"actions": { | |
"Initialise_Backup": { | |
"type": "InitializeVariable", | |
"runAfter": {}, | |
"inputs": { | |
"variables": [ | |
{ | |
"type": "Object", | |
"name": "Backup", | |
"value": "@json('{}')" | |
} | |
] | |
} | |
}, | |
"List_Backups": { | |
"type": "ApiConnection", | |
"runAfter": { | |
"Initialise_Backup": [ | |
"Succeeded" | |
] | |
}, | |
"inputs": { | |
"method": "GET", | |
"host": { | |
"connection": { | |
"name": "@parameters('$connections')['azureblob']['connectionId']" | |
} | |
}, | |
"path": "/datasets/default/foldersV2/@{encodeURIComponent(encodeURIComponent(parameters('azureBlob')['containerName']))}", | |
"queries": { | |
"nextPageMarker": "", | |
"useFlatListing": false | |
} | |
} | |
}, | |
"Get_Latest_Backup": { | |
"type": "JavaScriptCode", | |
"runAfter": { | |
"List_Backups": [ | |
"Succeeded" | |
] | |
}, | |
"inputs": { | |
"code": "\"use strict\";\nvar items = workflowContext.actions.List_Backups.outputs.body.value;\nvar sorted = items.sort(function (a, b) {\n var dateA = a.Name.replace('.json', '');\n var dateB = b.Name.replace('.json', '');\n\n if (dateA > dateB) {\n return -1;\n }\n\n if (dateA < dateB) {\n return 1;\n }\n\n return 0;\n});\nvar result = sorted[0].Path;\nreturn result;\n\n" | |
} | |
}, | |
"Get_Backup": { | |
"type": "ApiConnection", | |
"runAfter": { | |
"Get_Latest_Backup": [ | |
"Succeeded" | |
] | |
}, | |
"inputs": { | |
"method": "GET", | |
"host": { | |
"connection": { | |
"name": "@parameters('$connections')['azureblob']['connectionId']" | |
} | |
}, | |
"path": "/datasets/default/GetFileContentByPath", | |
"queries": { | |
"inferContentType": true, | |
"path": "@{outputs('Get_Latest_Backup')?['body']}", | |
"queryParametersSingleEncoded": true | |
} | |
} | |
}, | |
"Get_BackupItems": { | |
"type": "Compose", | |
"runAfter": { | |
"Get_Backup": [ | |
"Succeeded" | |
] | |
}, | |
"inputs": "@json(base64ToString(body('Get_Backup')?['$content']))" | |
}, | |
"Loop_BackupItems": { | |
"type": "Foreach", | |
"runAfter": { | |
"Get_BackupItems": [ | |
"Succeeded" | |
] | |
}, | |
"foreach": "@outputs('Get_BackupItems')", | |
"runtimeConfiguration": { | |
"concurrency": { | |
"repetitions": 50 | |
} | |
}, | |
"actions": { | |
"Restore_BackupItem": { | |
"type": "Http", | |
"runAfter": {}, | |
"inputs": { | |
"method": "POST", | |
"uri": "@concat(parameters('keyVault')['baseUrl'], 'secrets/restore')", | |
"body": "@items('Loop_BackupItems')", | |
"queries": { | |
"api-version": "@{parameters('keyVault')['apiVersion']}" | |
}, | |
"authentication": { | |
"audience": "@parameters('keyVault')['audienceUrl']", | |
"type": "ManagedServiceIdentity" | |
} | |
} | |
} | |
} | |
}, | |
"List_Secrets": { | |
"type": "Http", | |
"runAfter": { | |
"Loop_BackupItems": [ | |
"Succeeded" | |
] | |
}, | |
"inputs": { | |
"method": "GET", | |
"uri": "@concat(parameters('keyVault')['baseUrl'], 'secrets')", | |
"queries": { | |
"api-version": "@{parameters('keyVault')['apiVersion']}" | |
}, | |
"authentication": { | |
"audience": "@parameters('keyVault')['audienceUrl']", | |
"type": "ManagedServiceIdentity" | |
} | |
} | |
} | |
}, | |
"outputs": {} | |
} | |
} |