Azure资源模板依赖关系/应用程序洞察

前端之家收集整理的这篇文章主要介绍了Azure资源模板依赖关系/应用程序洞察前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个鸡和蛋问题,将我的Web应用程序部署Application Insights到Azure.在ARM模板中,Application Insights模块依赖于应用程序ID的Web站点(请参阅下面的ARM模板中的依赖项).另一方面,为了完全检测Web应用程序,我需要Application Insights模块中的检测键.怎么绕过这个?

门户网站中的应用程序洞察视图

用于Web App的ARM模板

应用程序洞察的ARM模板

解决方案是将连接字符串和应用程序设置创建为网站的嵌套子资源.通过使用子资源策略,可以使appsettings依赖于网站和应用程序洞察.这允许按以下顺序进行配置:

>网站
>应用见解
>网站配置/ appsettings

以下两个答案很有帮助.第一个说明了如何提取检测密钥.第二个示例说明如何将应用程序设置和连接字符串嵌套为网站的子资源.

How to pull the instrumentation key

How to nest app settings as child resources

这是我的最终模板:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","contentVersion": "1.0.0.0","parameters": {
    "webSiteName": {
      "type": "string"
    },"aadTenant": {
      "type": "string"
    },"aadAudience": {
      "type": "string"
    },"endpoints": {
      "type": "string","defaultValue": "n/a"
    },"apiEndpoint": {
      "type": "string","sqlConnStrName": {
      "type": "string"
    },"sqlConnStrValue": {
      "type": "string"
    },"skuName": {
      "type": "string","defaultValue": "F1","allowedValues": [
        "F1","D1","B1","B2","B3","S1","S2","S3","P1","P2","P3","P4"
      ],"Metadata": {
        "description": "Describes plan's pricing tier and instance size. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
      }
    },"skuCapacity": {
      "type": "int","defaultValue": 1,"minValue": 1,"Metadata": {
        "description": "Describes plan's instance count"
      }
    }
  },"variables": {
    "hostingPlanName": "[concat(parameters('webSiteName'),'-hostingplan')]"
  },"resources": [
    {
      "apiVersion": "2015-08-01","name": "[variables('hostingPlanName')]","type": "Microsoft.Web/serverfarms","location": "[resourceGroup().location]","tags": {
        "displayName": "HostingPlan"
      },"sku": {
        "name": "[parameters('skuName')]","capacity": "[parameters('skuCapacity')]"
      },"properties": {
        "name": "[variables('hostingPlanName')]"
      }
    },{
      "apiVersion": "2015-08-01","name": "[parameters('webSiteName')]","type": "Microsoft.Web/sites","dependsOn": [
        "[variables('hostingPlanName')]"
      ],"tags": {
        "[concat('hidden-related:',resourceId('Microsoft.Web/serverfarms',variables('hostingPlanName')))]": "empty","displayName": "Website"
      },"properties": {
        "name": "[parameters('webSiteName')]","serverFarmId": "[resourceId('Microsoft.Web/serverfarms',variables('hostingPlanName'))]"
      },"resources": [
        {
          "apiVersion": "2015-08-01","name": "appsettings","type": "config","dependsOn": [
            "[parameters('webSiteName')]","[concat('AppInsights',parameters('webSiteName'))]"
          ],"properties": {
            "ida:Tenant": "[parameters('aadTenant')]","ida:Audience": "[parameters('aadAudience')]","endpoints": "[parameters('endpoints')]","apiEndpoint": "[parameters('apiEndpoint')]","applicationInsightsInstrumentationKey": "[reference(resourceId('Microsoft.Insights/components',concat('AppInsights',parameters('webSiteName'))),'2014-04-01').InstrumentationKey]"
          }
        },{
          "apiVersion": "2015-08-01","name": "connectionstrings","dependsOn": [
            "[parameters('webSiteName')]"
          ],"properties": {
            "[parameters('sqlConnStrName')]": {
              "value": "[parameters('sqlConnStrValue')]","type": "sqlServer"
            }
          }
        },"name": "logs","properties": {
            "applicationLogs": {
              "fileSystem": {
                "level": "Off"
              },"azureTableStorage": {
                "level": "Off","sasUrl": null
              },"azureBlobStorage": {
                "level": "Information","sasUrl": "TO DO: pass in a SAS Url","retentionInDays": null
              }
            },"httpLogs": {
              "fileSystem": {
                "retentionInMb": 40,"enabled": true
              }
            },"FailedRequestsTracing": {
              "enabled": true
            },"detailedErrorMessages": {
              "enabled": true
            }
          }
        }
      ]
    },{
      "apiVersion": "2014-04-01","name": "[concat(variables('hostingPlanName'),'-',resourceGroup().name)]","type": "Microsoft.Insights/autoscalesettings","tags": {
        "[concat('hidden-link:',variables('hostingPlanName')))]": "Resource","displayName": "AutoScaleSettings"
      },"properties": {
        "profiles": [
          {
            "name": "Default","capacity": {
              "minimum": 1,"maximum": 2,"default": 1
            },"rules": [
              {
                "metricTrigger": {
                  "metricName": "cpuPercentage","metricResourceUri": "[resourceId('Microsoft.Web/serverfarms',variables('hostingPlanName'))]","timeGrain": "PT1M","statistic": "Average","timeWindow": "PT10M","timeAggregation": "Average","operator": "GreaterThan","threshold": 80.0
                },"scaleAction": {
                  "direction": "Increase","type": "ChangeCount","value": 1,"cooldown": "PT10M"
                }
              },{
                "metricTrigger": {
                  "metricName": "cpuPercentage","timeWindow": "PT1H","operator": "LessThan","threshold": 60.0
                },"scaleAction": {
                  "direction": "Decrease","cooldown": "PT1H"
                }
              }
            ]
          }
        ],"enabled": false,"targetResourceUri": "[resourceId('Microsoft.Web/serverfarms',variables('hostingPlanName'))]"
      }
    },"name": "[concat('ServerErrors ',parameters('webSiteName'))]","type": "Microsoft.Insights/alertrules","dependsOn": [
        "[parameters('webSiteName')]"
      ],resourceId('Microsoft.Web/sites',parameters('webSiteName')))]": "Resource","displayName": "ServerErrorsAlertRule"
      },"properties": {
        "name": "[concat('ServerErrors ',"description": "[concat(parameters('webSiteName'),' has some server errors,status code 5xx.')]","isEnabled": true,"condition": {
          "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition","dataSource": {
            "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource","resourceUri": "[resourceId('Microsoft.Web/sites',"metricName": "Http5xx"
          },"threshold": 5.0,"windowSize": "PT5M"
        },"action": {
          "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleEmailAction","sendToServiceOwners": true,"customEmails": ["you@example.com"]
        }
      }
    },"name": "[concat('ForbiddenRequests ',"displayName": "ForbiddenRequestsAlertRule"
      },"properties": {
        "name": "[concat('ForbiddenRequests ',' has some requests that are forbidden,status code 403.')]","metricName": "Http403"
          },"threshold": 5,"customEmails": [ ]
        }
      }
    },"name": "[concat('cpuHigh ',"displayName": "cpuHighAlertRule"
      },"properties": {
        "name": "[concat('cpuHigh ',"description": "[concat('The average cpu is high across all the instances of ',"isEnabled": false,"resourceUri": "[resourceId('Microsoft.Web/serverfarms',"metricName": "cpuPercentage"
          },"threshold": 90,"windowSize": "PT15M"
        },"name": "[concat('LongHttpQueue ',"properties": {
        "name": "[concat('LongHttpQueue ',"description": "[concat('The HTTP queue for the instances of ',variables('hostingPlanName'),' has a large number of pending requests.')]","resourceUri": "[concat(resourceGroup().id,'/providers/Microsoft.Web/serverfarms/',"metricName": "HttpQueueLength"
          },"threshold": 100.0,"name": "[concat('AppInsights',"type": "Microsoft.Insights/components","location": "Central US","displayName": "AppInsightsComponent"
      },"properties": {
        "ApplicationId": "[parameters('webSiteName')]"
      }
    }
  ],"outputs": {
    "siteUri": {
      "type": "string","value": "[reference(concat('Microsoft.Web/sites/',parameters('webSiteName')),'2015-08-01').hostnames[0]]"
    }
  }

}
原文链接:https://www.f2er.com/javaschema/281568.html

猜你在找的设计模式相关文章