我正在尝试部署一个Azure函数,其中压缩的内容已放在另一个订阅和资源组中的blob中。函数应用程序被部署,但在它下面没有函数,并且MSDeploy失败并超时-
"provisioningOperation": "Create",
"provisioningState": "Failed",
"timestamp": "2021-07-23T15:10:45.9602877Z",
"duration": "PT2H11.3363166S",
"serviceRequestId": "17787274-8592-465b-a11e-10aada76286e",
"statusCode": "RequestTimeout",
"statusMessage": {
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource provision operation did not complete within the allowed timeout period."
}
},
"targetResource": {
"id": "/subscriptions/<sub-id>/resourceGroups/rg-7ND96/providers/Microsoft.Web/sites/FnAppubjba74tmczo4/Extensions/MSDeploy",
"resourceName": "FnAppubjba74tmczo4/MSDeploy",
"resourceType": "Microsoft.Web/sites/Extensions"
我假设发生这种情况是因为MSDeploy无法访问blob中的zip文件。我没有提供任何明确的访问权限,我也不知道该怎么做。下面是我的ARM模板的功能app -
{
"type": "Microsoft.Web/sites",
"apiVersion": "2020-06-01",
"name": "[variables('functionAppName')]",
"location": "[parameters('location')]",
"kind": "functionapp",
"properties": {
"name": "[variables('functionAppName')]",
"clientAffinityEnabled": false
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"[resourceId('Microsoft.Insights/components', variables('appInsightsName'))]"
],
"resources": [
{
"apiVersion": "2018-11-01",
"name": "appsettings",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('functionAppName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"[resourceId('Microsoft.Insights/components', variables('appInsightsName'))]"
],
"properties": {
"AzureWebJobsStorage": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value)]",
"FUNCTIONS_EXTENSION_VERSION": "~3",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value)]",
"FileStorageAccountConnectionString": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';EndpointSuffix=', environment().suffixes.storage, ';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value)]",
"FileShareName": "[variables('fileShareName')]",
"APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').InstrumentationKey]"
}
},
{
"name": "MSDeploy",
"type": "Extensions",
"apiVersion": "2018-11-01",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]"
],
"properties": {
"packageUri": "https://storage-name.blob.core.windows.net/Function.zip",
"appOffline": true
}
}
]
}
在MSDeploy资源运行之前,我可以在ARM模板中动态地使用托管身份提供函数应用程序对blob的访问吗?如果没有,我可以在ARM模板中生成SAS令牌进行访问吗?
UPADTE -我去检查中已部署功能应用程序的日志..homeLogFilesSiteExtensionsMSDeploy- appManagerLog.xml -
<?xml version="1.0" encoding="utf-8"?>
<entries>
<entry time="2021-07-23T15:13:08.5448175+00:00" type="Message">
<message>Downloading package path 'Function.zip' from blob 'https://storage-name.blob.core.windows.net'</message>
</entry>
<entry time="2021-07-23T15:13:09.0604383+00:00" type="Message">
<message>No parameters were populated.</message>
</entry>
<entry time="2021-07-23T15:13:09.0604383+00:00" type="Message">
<message>AppOffline enabled</message>
</entry>
<entry time="2021-07-23T15:13:09.0604383+00:00" type="Message">
<message>Calling SyncTo() on package.</message>
</entry>
<entry time="2021-07-23T15:13:09.3104411+00:00" type="Message">
<message>Adding file (.FunctionApp.csproj).</message>
</entry>
<entry time="2021-07-23T15:13:09.3104411+00:00" type="Message">
<message>Adding file (.FunctionApp.csproj).</message>
</entry>
<entry time="2021-07-23T15:13:09.3729946+00:00" type="Message">
<message>Deleting file (.host.json).</message>
</entry>
<entry time="2021-07-23T15:13:09.3729946+00:00" type="Message">
<message>Deleting file (.host.json).</message>
</entry>
<entry time="2021-07-23T15:13:09.4199523+00:00" type="Message">
<message>Adding file (.local.settings.json).</message>
</entry>
<entry time="2021-07-23T15:13:09.4199523+00:00" type="Message">
<message>Adding file (.local.settings.json).</message>
</entry>
<entry time="2021-07-23T15:13:09.4823395+00:00" type="Message">
<message>Adding directory (.Models).</message>
</entry>
<entry time="2021-07-23T15:13:09.4823395+00:00" type="Message">
<message>Adding directory (.Models).</message>
</entry>
<entry time="2021-07-23T15:13:09.529223+00:00" type="Message">
<message>Adding file (.ModelsRequestModel.cs).</message>
</entry>
<entry time="2021-07-23T15:13:09.529223+00:00" type="Message">
<message>Adding file (.ModelsRequestModel.cs).</message>
</entry>
<entry time="2021-07-23T15:13:09.5917233+00:00" type="Message">
<message>Adding file (.ModelsState.cs).</message>
</entry>
<entry time="2021-07-23T15:13:09.5917233+00:00" type="Message">
<message>Adding file (.ModelsState.cs).</message>
</entry>
<entry time="2021-07-23T15:13:09.654252+00:00" type="Message">
<message>Adding file (.ModelsStateInfo.cs).</message>
</entry>
<entry time="2021-07-23T15:13:09.654252+00:00" type="Message">
<message>Adding file (.ModelsStateInfo.cs).</message>
</entry>
<entry time="2021-07-23T15:13:09.716655+00:00" type="Message">
<message>Adding file (.ResponseFunction.cs).</message>
</entry>
<entry time="2021-07-23T15:13:09.716655+00:00" type="Message">
<message>Adding file (.ResponseFunction.cs).</message>
</entry>
<entry time="2021-07-23T15:13:09.8729031+00:00" type="Message">
<message>Total Changes: 8 (7 added, 1 deleted, 0 updated, 0 parameters changed, 7989 bytes copied)</message>
</entry>
<entry time="2021-07-23T15:13:09.8729031+00:00" type="Message">
<message>[Information] [user: F8C3B4564BD880EEFBE19EBA84667977B183FC6B] [324886c5-3416-4866-b8b4-5c3a2ed83394] WebDeploy operation complete. Performing post-deployment operations.</message>
</entry>
<entry time="2021-07-23T15:13:10.6130904+00:00" type="Message">
<message>[Verbose] [user: F8C3B4564BD880EEFBE19EBA84667977B183FC6B] Begin HttpPost https://adobefnappubjba74tmczo4.azurewebsites.net/admin/host/synctriggers, x-ms-request-id: 324886c5-3416-4866-b8b4-5c3a2ed83394</message>
</entry>
<entry time="2021-07-23T15:16:47.9939772+00:00" type="Message">
<message>Downloading package path 'Function.zip' from blob 'https://storage-name.blob.core.windows.net'</message>
</entry>
<entry time="2021-07-23T15:16:48.0721032+00:00" type="Message">
<message>No parameters were populated.</message>
</entry>
<entry time="2021-07-23T15:16:48.0721032+00:00" type="Message">
<message>AppOffline enabled</message>
</entry>
<entry time="2021-07-23T15:16:48.0721032+00:00" type="Message">
<message>Calling SyncTo() on package.</message>
</entry>
<entry time="2021-07-23T15:16:48.1502509+00:00" type="Message">
<message>Deleting file (.host.json).</message>
</entry>
<entry time="2021-07-23T15:16:48.1502509+00:00" type="Message">
<message>Deleting file (.host.json).</message>
</entry>
<entry time="2021-07-23T15:16:48.2596268+00:00" type="Message">
<message>Total Changes: 1 (0 added, 1 deleted, 0 updated, 0 parameters changed, 0 bytes copied)</message>
</entry>
<entry time="2021-07-23T15:16:48.2596268+00:00" type="Message">
<message>[Information] [user: F8C3B4564BD880EEFBE19EBA84667977B183FC6B] [ae7d2678-ec79-476b-8e72-e3a4e4cc0d70] WebDeploy operation complete. Performing post-deployment operations.</message>
</entry>
<entry time="2021-07-23T15:16:48.3221254+00:00" type="Message">
<message>[Verbose] [user: F8C3B4564BD880EEFBE19EBA84667977B183FC6B] Begin HttpPost https://adobefnappubjba74tmczo4.azurewebsites.net/admin/host/synctriggers, x-ms-request-id: ae7d2678-ec79-476b-8e72-e3a4e4cc0d70</message>
</entry>
<entry time="2021-07-23T15:21:42.6541756Z" type="Message">
<message>Downloading package path 'Function.zip' from blob 'https://storage-name.blob.core.windows.net'</message>
</entry>
<entry time="2021-07-23T15:21:42.7318456Z" type="Message">
<message>No parameters were populated.</message>
</entry>
<entry time="2021-07-23T15:21:42.7318456Z" type="Message">
<message>AppOffline enabled</message>
</entry>
<entry time="2021-07-23T15:21:42.7318456Z" type="Message">
<message>Calling SyncTo() on package.</message>
</entry>
<entry time="2021-07-23T15:21:42.8099044Z" type="Message">
<message>Deleting file (.host.json).</message>
</entry>
<entry time="2021-07-23T15:21:42.8099044Z" type="Message">
<message>Deleting file (.host.json).</message>
</entry>
<entry time="2021-07-23T15:21:42.8880416Z" type="Message">
<message>Total Changes: 1 (0 added, 1 deleted, 0 updated, 0 parameters changed, 0 bytes copied)</message>
</entry>
<entry time="2021-07-23T15:21:42.8880416Z" type="Message">
<message>[Information] [user: F8C3B4564BD880EEFBE19EBA84667977B183FC6B] [6b7c0ba0-8504-4525-9f99-a5e7d787693f] WebDeploy operation complete. Performing post-deployment operations.</message>
</entry>
<entry time="2021-07-23T15:21:42.9505549Z" type="Message">
<message>[Verbose] [user: F8C3B4564BD880EEFBE19EBA84667977B183FC6B] Begin HttpPost https://adobefnappubjba74tmczo4.azurewebsites.net/admin/host/synctriggers, x-ms-request-id: 6b7c0ba0-8504-4525-9f99-a5e7d787693f</message>
</entry>
</entries>
从日志中可以看出MSDeploy确实可以访问blob,因为正在读取所有文件夹。然而,我的部署失败了,当我转到Azure门户到部署的函数应用程序时,它下面没有函数。我遗漏了什么吗?
您的包URI应该包含共享访问签名(SAS)
"packageUri": "https://storage-name.blob.core.windows.net/Function.zip?sv=yourSAS",
为此,在Azure存储资源管理器中创建共享访问签名(SAS)令牌用于存储容器,然后将令牌追加到WDP url。记下包的url以便以后在ARM中使用模板。
在你的例子中,wdp是一个zip文件,相同但不同。
一个SAS URI看起来像这样:
https://contoso.blob.core.windows.net/container01?sv=2020-04-08&st=2021-03-02T00%3A30%3A33Z&se=2020-03-03T00%3A30%3A33Z&sr=c&sp=rl&sig=z9VFdWffrV6FXU51T8b8HVfipZPOpYOFLXuQw6wfkFY%3F
在连接到Azure存储对话框的选择资源面板中,选择要连接的资源。选择共享访问签名(SAS),选择"下一步"。输入显示名称连接和资源的SAS URI。选择Next。回顾你的Summary面板中的连接信息。如果连接如果信息正确,请选择"连接"。
From microsoft doc