почему шаблон ARM создает отдельный план обслуживания приложения? - PullRequest
0 голосов
/ 01 января 2019

Я хотел бы понять, почему был создан весь план обслуживания приложения , а не просто функция Azure вместе с информацией о приложении:

enter image description here

Разве невозможно создать приложение-функцию Azure без принудительного создания плана обслуживания приложения?

enter image description here

Как создать функцию Azure с использованием шаблона ARM, не создавая компонент плана обслуживания приложения?

Вот мой полный шаблон:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "type": "string"
        },
        "storageAccountName": {
            "type": "string"
        },
        "accountType": {
            "type": "string"
        },
        "appName": {
            "type": "string"
        }
    },
    "variables": {
        "storageAccessTier": "Hot",
        "storageKind": "StorageV2",
        "supportsHttpsTrafficOnly": true,
        "functionAppName": "[parameters('appName')]",
        "applicationInsightsName": "[parameters('appName')]",
        "storageAccountName": "[parameters('storageAccountName')]",
        "storageAccountid": "[concat(resourceGroup().id,'/providers/','Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]"
    },
    "resources": [
        {
            "name": "[variables('storageAccountName')]",
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2018-07-01",
            "location": "[parameters('location')]",
            "properties": {
                "accessTier": "[variables('storageAccessTier')]",
                "supportsHttpsTrafficOnly": "[variables('supportsHttpsTrafficOnly')]"
            },
            "dependsOn": [],
            "sku": {
                "name": "[parameters('accountType')]"
            },
            "kind": "[variables('storageKind')]"
        },
        {
            "apiVersion": "2015-08-01",
            "type": "Microsoft.Web/sites",
            "name": "[variables('functionAppName')]",
            "location": "[parameters('location')]",
            "kind": "functionapp",
            "dependsOn": [
                "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
            ],
            "properties": {
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "AzureWebJobsDashboard",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
                        },
                        {
                            "name": "AzureWebJobsStorage",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
                        },
                        {
                            "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
                        },
                        {
                            "name": "WEBSITE_CONTENTSHARE",
                            "value": "[toLower(variables('functionAppName'))]"
                        },
                        {
                            "name": "FUNCTIONS_EXTENSION_VERSION",
                            "value": "~1"
                        },
                        {
                            "name": "WEBSITE_NODE_DEFAULT_VERSION",
                            "value": "6.5.0"
                        },
                        {
                            "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                            "value": "[reference(resourceId('microsoft.insights/components/', variables('applicationInsightsName')), '2015-05-01').InstrumentationKey]"
                        }
                    ]
                }
            }
        },
        {
            "apiVersion": "2018-05-01-preview",
            "name": "[variables('applicationInsightsName')]",
            "type": "microsoft.insights/components",
            "location": "[parameters('location')]",
            "tags": {
                "[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('applicationInsightsName'))]": "Resource"
            },
            "properties": {
                "ApplicationId": "[variables('applicationInsightsName')]",
                "Request_Source": "IbizaWebAppExtensionCreate"
            }
        }
    ],
    "outputs": {}
}

Ответы [ 2 ]

0 голосов
/ 02 января 2019

Вы можете пропустить serverFarmId в вашем шаблоне.Попробуйте шаблон ниже, он не будет создавать отдельный план обслуживания приложения, в моем примере он присоединяет Function App к существующему плану обслуживания приложения joyplan и учетной записи хранения joystoragev1, создает представление приложения joytestfuninsight и присоединяется к нему..

Образец:

{
    "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "type": "String"
        },
        "storageName": {
            "type": "String"
        },
        "hostingPlanName": {
            "type": "String"
        },
        "location": {
            "type": "String"
        },
        "serverFarmResourceGroup": {
            "type": "String"
        },
        "subscriptionId": {
            "type": "String"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Web/sites",
            "kind": "functionapp",
            "name": "[parameters('name')]",
            "apiVersion": "2016-03-01",
            "location": "[parameters('location')]",
            "properties": {
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "FUNCTIONS_WORKER_RUNTIME",
                            "value": "dotnet"
                        },
                        {
                            "name": "AzureWebJobsStorage",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageName'),';AccountKey=',listKeys(resourceId('b83c1ed3-c5b6-44fb-b5ba-2b83a074c23f','joywebapp','Microsoft.Storage/storageAccounts', parameters('storageName')), '2015-05-01-preview').key1)]"
                        },
                        {
                            "name": "FUNCTIONS_EXTENSION_VERSION",
                            "value": "~2"
                        },
                        {
                            "name": "WEBSITE_NODE_DEFAULT_VERSION",
                            "value": "8.11.1"
                        },
                        {
                            "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                            "value": "[reference('microsoft.insights/components/joytestfuninsight', '2015-05-01').InstrumentationKey]"
                        }
                    ],
                    "alwaysOn": true
                },
                "name": "[parameters('name')]",
                "clientAffinityEnabled": false,
                "serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
            },
            "dependsOn": [
                "microsoft.insights/components/joytestfuninsight"
            ]
        },
        {
            "type": "microsoft.insights/components",
            "name": "joytestfuninsight",
            "apiVersion": "2015-05-01",
            "location": "eastus",
            "properties": {
                "ApplicationId": "[parameters('name')]",
                "Request_Source": "IbizaWebAppExtensionCreate"
            }
        }
    ]
}

Мои тестовые параметры:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "value": "joytestfun"
        },
        "storageName": {
            "value": "joystoragev1"
        },
        "hostingPlanName": {
            "value": "joyplan"
        },
        "location": {
            "value": "Central US"
        },
        "serverFarmResourceGroup": {
            "value": "joywebapp"
        },
        "subscriptionId": {
            "value": "xxxxxxxxxxxxxxxxxxxx"
        }
    }
}

Обновление :

Если вы хотите создатьФункциональное приложение с планом потребления, вы можете обратиться к шаблону ниже.

Образец:

{
    "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "type": "String"
        },
        "storageName": {
            "type": "String"
        },
        "location": {
            "type": "String"
        },
        "subscriptionId": {
            "type": "String"
        }
    },
    "resources": [
        {
            "type": "Microsoft.Web/sites",
            "kind": "functionapp",
            "name": "[parameters('name')]",
            "apiVersion": "2016-03-01",
            "location": "Central US",
            "properties": {
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "FUNCTIONS_WORKER_RUNTIME",
                            "value": "dotnet"
                        },
                        {
                            "name": "AzureWebJobsStorage",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageName'),';AccountKey=',listKeys(resourceId('b83c1ed3-xxxxxxxxxxx-2b83a074c23f','joywebapp','Microsoft.Storage/storageAccounts', parameters('storageName')), '2015-05-01-preview').key1)]"
                        },
                        {
                            "name": "FUNCTIONS_EXTENSION_VERSION",
                            "value": "~2"
                        },
                        {
                            "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=',parameters('storageName'),';AccountKey=',listKeys(resourceId('b83c1ed3-xxxxxxxxxxx-2b83a074c23f','joywebapp','Microsoft.Storage/storageAccounts', parameters('storageName')), '2015-05-01-preview').key1)]"
                        },
                        {
                            "name": "WEBSITE_CONTENTSHARE",
                            "value": "[concat(toLower(parameters('name')), 'b32d')]"
                        },
                        {
                            "name": "WEBSITE_NODE_DEFAULT_VERSION",
                            "value": "8.11.1"
                        },
                        {
                            "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                            "value": "[reference('microsoft.insights/components/joytest11insight', '2015-05-01').InstrumentationKey]"
                        }
                    ]
                },
                "name": "[parameters('name')]",
                "clientAffinityEnabled": false,
                "reserved": false
            },
            "dependsOn": [
                "microsoft.insights/components/joytest11insight"
            ]
        },
        {
            "type": "microsoft.insights/components",
            "name": "joytest11insight",
            "apiVersion": "2015-05-01",
            "location": "eastus",
            "properties": {
                "ApplicationId": "[parameters('name')]",
                "Request_Source": "IbizaWebAppExtensionCreate"
            }
        }
    ]
}

Мои параметры теста:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "name": {
            "value": "joytest11"
        },
        "storageName": {
            "value": "joystoragev1"
        },
        "location": {
            "value": "central us"
        },
        "subscriptionId": {
            "value": "b83c1ed3-xxxxxxxxxxx-2b83a074c23f"
        }
    }
}
0 голосов
/ 01 января 2019

Для работы функции Azure требуется план обслуживания приложения, поэтому вы не можете создать функцию Azure без него.

Вы можете присоединить новую функцию Azure к уже существующему плану службы приложения, вот и все.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...