我已经在线搜索并浏览了可用的powershell cmdlet,以尝试找到解决该问题的方法,但未成功。本质上,我有一些Data Factory管道可以复制/存档传入文件,并将使用Web http post组件,该组件将调用连接到Blob容器的Logic App并删除传入文件。我面临的问题是,我们有几本自动化运行手册,每隔X天都会放置一次Blob访问键。当Blob键重置时,只要发生这种情况,Logic App都会失败,因为连接是在设计器本身中手动创建的,例如,我无法指定可能从Keyvault中提取的连接字符串。在{Logic App> API连接>编辑API连接}内,我们可以手动更新连接字符串/键,但是显然对于自动化过程,我们应该能够以编程方式进行此操作。
是否没有Powershell cmdlet或其他方法可以使我更新/编辑在Logic App中使用和Blob组件时创建的API连接?
任何见解都值得赞赏!
答案 0 :(得分:2)
在存储帐户中旋转密钥后,可以使用ARM模板来更新连接API。在此ARM模板中,创建了连接api,该连接api在内部引用了存储帐户,因此您不必提供密钥:
azuredeploy.json 文件:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"azureBlobConnectionAPIName": {
"type": "string",
"metadata": {
"description": "The name of the connection api to access the azure blob storage."
}
},
"storageAccountName": {
"type": "string",
"metadata": {
"description": "The Storage Account Name."
}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections",
"name": "[parameters('azureBlobConnectionAPIName')]",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"displayName": "[parameters('azureBlobConnectionAPIName')]",
"parameterValues": {
"accountName": "[parameters('storageAccountName')]",
"accessKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')),'2015-05-01-preview').key1]"
},
"api": {
"id": "[concat('subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/azureblob')]"
}
},
"dependsOn": []
}
]
}
azuredeploy.parameters.json 文件:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"azureBlobConnectionAPIName": {
"value": "myblobConnectionApiName"
},
"storageAccountName": {
"value": "myStorageAccountName"
}
}
}
您可以像这样执行手臂模板:
Connect-AzureRmAccount
Select-AzureRmSubscription -SubscriptionName <yourSubscriptionName>
New-AzureRmResourceGroupDeployment -Name "ExampleDeployment" -ResourceGroupName "MyResourceGroupName" `
-TemplateFile "D:\Azure\Templates\azuredeploy.json" `
-TemplateParameterFile "D:\Azure\Templates\azuredeploy.parameters.json"
要开始使用ARM模板和powerhsell,请看一下本文:
Deploy resources with Resource Manager templates and Azure PowerShell