gpt4 book ai didi

Azure 资源管理器模板 - 将 dacpac 和两个 Web 项目部署到一个 Web 应用程序中

转载 作者:行者123 更新时间:2023-12-03 00:32:14 24 4
gpt4 key购买 nike

我们正在尝试使用 ARM 来申请并将相当复杂的设置部署到 Azure 中。以下是基本组件:

  • 2 个 Web 项目应放入一个 Web 应用程序中,其中一个放入虚拟应用程序中子目录
  • 同一数据库服务器上的 2 个 Sql 数据库,使用 DACPAC(不是 bacpac)
  • Azure 服务总线
  • 中间件虚拟机
  • 其他一些东西

我已经完成了大部分工作。我似乎不知道该怎么做的两个主要部分:

  1. 我找不到进行 DACPAC 部署的模板或方法。我们的模式位于 Sql 数据库项目中,它可以整齐地编译为 dacpac 格式。我期望能够使用 Azure 资源组部署项目将其添加到 ARM 部署模板中。但到目前为止,我只能找到一种使用 BACPAC 文件进行数据库导入的方法,这在我们的例子中没有多大意义。
  2. 我正在尝试找到一种方法将两个单独的 Web 项目部署到 Azure Web 应用程序中,但部署到两个不同的虚拟应用程序中。我找到了一种在一个 WebDeploy 上配置虚拟应用程序路径的方法,但无法将第二个项目添加到同一 WebSite 节点中。

以下是一个应用程序网站的部署模板的片段:

{
"name": "[variables('UxWebAppName')]",
"type": "Microsoft.Web/sites",
"location": "[resourceGroup().location]",
"apiVersion": "2015-08-01",
"dependsOn": [
"[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
],
"tags": {
"[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
"displayName": "UxWebApp"
},
"properties": {
"name": "[variables('UxWebAppName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
},
"resources": [
{
"apiVersion": "2015-08-01",
"name": "web",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('UxWebAppName'))]"
],
"properties": {
"phpVersion": "5.5",
"netFrameworkVersion": "v4.6",
"use32BitWorkerProcess": false, /* 64-bit platform */
"webSocketsEnabled": true,
"alwaysOn": true,
"remoteDebuggingEnabled": false,
"virtualApplications": [
{
"virtualPath": "/",
"physicalPath": "site\\wwwroot"
},
{
"virtualPath": "/api",
"physicalPath": "site\\wwwroot\\api"
}
],

"defaultDocuments": [
"index.html",
"hostingstart.html"
]
}
},
{
"name": "MSDeploy",
"type": "extensions",
"location": "[resourceGroup().location]",
"apiVersion": "2015-08-01",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('UxWebAppName'))]"
],
"tags": {
"displayName": "UxDeploy"
},
"properties": {
"packageUri": "[concat(parameters('_artifactsLocation'), '/', parameters('UxDeployPackageFolder'), '/', parameters('UxDeployPackageFileName'), parameters('_artifactsLocationSasToken'))]",
"dbType": "None",
"connectionString": "",
"setParameters": {
"IIS Web Application Name": "[variables('UxWebAppName')]"
}
}
}

我试图添加第二个 MSDeploy 扩展元素,但这在部署期间导致错误,提示存在重复节点。

这是 sql server 部分的代码片段:

{
"name": "[variables('sqlserverName')]",
"type": "Microsoft.Sql/servers",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "SqlServer"
},
"apiVersion": "2014-04-01-preview",
"properties": {
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]"
},
"resources": [
{
"name": "[parameters('coreDatabaseName')]",
"type": "databases",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "CoreDatabase"
},
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', variables('sqlserverName'))]"
],
"properties": {
"edition": "[parameters('edition')]",
"collation": "[parameters('collation')]",
"maxSizeBytes": "[parameters('maxSizeBytes')]",
"requestedServiceObjectiveName": "[parameters('requestedServiceObjectiveName')]"
},
"resources": [
{
"name": "Import",
"type": "extensions",
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[parameters('coreDatabaseName')]"
],
"tags": {
"displayName": "CoreDb"
},
"properties": {
"storageKeyType": "[parameters('CoreDbStorageKeyType')]",
"storageKey": "[parameters('primaryKey')]",
"storageUri": "[concat(parameters('_artifactsLocation'), '/', parameters('CoreDbStoragePackageFolder'), '/', parameters('CoreDbStoragePackageFileName'))]",
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]",
"operationMode": "Import"
}
}
]
},
{
"type": "firewallrules",
"apiVersion": "2014-04-01-preview",
"dependsOn": [
"[concat('Microsoft.Sql/servers/', variables('sqlserverName'))]"
],
"location": "[resourceGroup().location]",
"name": "AllowAllWindowsAzureIps",
"properties": {
"endIpAddress": "0.0.0.0",
"startIpAddress": "0.0.0.0"
}
}
]
}

这似乎仅适用于 bacpac 文件,但不适用于 dacpac。我只是在网络上找不到任何关于此的有用信息。我发现可能有几个条目正在讨论将 dacpac 包含在网络应用程序项目中,但这种方法对我来说似乎很奇怪。我尝试将操作模式设置为发布(假设它在后台使用 sqlpackage),但它说不支持。

有人有使用 ARM 进行这两种类型部署的经验吗?或者我只是第一批尝试这样做的豚鼠之一?

我想我可以使用 powershell/msbuild 部署(我可以在其中指定虚拟目录等)分别执行 dacpac 和 Web 应用程序的部署,但据我所知,这违背了 ARM 的目的?

任何有用的提示都值得赞赏!

编辑 我可以在没有 ARM 的情况下进行部署,并使用 MSBuild 进行征用部分,如下所示:对于使用publishprofile的网络应用程序来说很容易

"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" ../xx/SomeApp.csproj /p:DeployOnBuild=true /p:PublishProfile=SomeApp.pubxml /p:VisualStudioVersion=12.0 /p:Password=******

对于这样的sql部署:

"C:\Program Files (x86)\Microsoft SQL Server\120\DAC\bin\sqlpackage.exe" /Action:Publish /SourceFile:"U:\bin\Database\Database.dacpac" /TargetConnectionString:"Server=some.database.windows.net,1433;Database=SomeDatabase;User ID=someUser;Password=*******;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" /p:GenerateSmartDefaults=True /p:RegisterDataTierApplication=True /p:BlockWhenDriftDetected=False /p:BlockOnPossibleDataLoss=False

问题纯粹是关于 ARM 模板部署。我的意思是,我可以拆分申请(使用 ARM)和部署(使用 msdeploy 或 Powershell DSC),但我认为我做得不对,因为部署的某些部分(例如 Web 包)正在工作。真的只支持一半的东西,但一半还没有?

最佳答案

关于Azure 资源管理器模板 - 将 dacpac 和两个 Web 项目部署到一个 Web 应用程序中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35172556/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com