You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

347 lines
10 KiB

5 years ago
  1. {
  2. "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  3. "contentVersion": "1.0.0.0",
  4. "parameters": {
  5. "appName": {
  6. "type": "string",
  7. "minLength": 1,
  8. "metadata": {
  9. "description": "The name for the webapp. Must be globally unique."
  10. }
  11. },
  12. "secretKey": {
  13. "type": "securestring",
  14. "minLength": 16,
  15. "metadata": {
  16. "description": "The value to use as the Django secret key."
  17. }
  18. },
  19. "adminUserName": {
  20. "type": "string",
  21. "minLength": 1,
  22. "metadata": {
  23. "description": "The user name for the admin account."
  24. }
  25. },
  26. "adminContactEmail": {
  27. "type": "string",
  28. "minLength": 1,
  29. "metadata": {
  30. "description": "The contact email address for the admin account."
  31. }
  32. },
  33. "adminPassword": {
  34. "type": "securestring",
  35. "minLength": 16,
  36. "maxLength": 50,
  37. "metadata": {
  38. "description": "The password for the admin account."
  39. }
  40. },
  41. "appServiceSku": {
  42. "type": "string",
  43. "defaultValue": "B2",
  44. "allowedValues": [
  45. "B1",
  46. "B2",
  47. "B3",
  48. "S1",
  49. "S2",
  50. "S3"
  51. ],
  52. "metadata": {
  53. "description": "The SKU of the webapp hosting tier."
  54. }
  55. },
  56. "sendgridSku": {
  57. "type": "string",
  58. "defaultValue": "free",
  59. "allowedValues": [
  60. "free",
  61. "bronze",
  62. "silver",
  63. "gold",
  64. "platinum",
  65. "premier"
  66. ],
  67. "metadata": {
  68. "description": "The SKU of the Sendgrid email account."
  69. }
  70. },
  71. "databaseCores": {
  72. "type": "int",
  73. "defaultValue": 2,
  74. "allowedValues": [
  75. 2,
  76. 4,
  77. 8,
  78. 16,
  79. 32,
  80. 64
  81. ],
  82. "metadata": {
  83. "description": "The number of vCores to provision for the PostgreSQL server."
  84. }
  85. },
  86. "databaseSize": {
  87. "type": "int",
  88. "minValue": 51200,
  89. "defaultValue": 51200,
  90. "metadata": {
  91. "description": "The storage capacity to provision for the PostgreSQL server."
  92. }
  93. },
  94. "databaseName": {
  95. "type": "string",
  96. "minLength": 1,
  97. "defaultValue": "doccano",
  98. "metadata": {
  99. "description": "The name of the database to provision on the PostgreSQL server."
  100. }
  101. },
  102. "dockerImageName": {
  103. "type": "string",
  104. "minLength": 1,
  105. "defaultValue": "doccano/doccano:latest",
  106. "metadata": {
  107. "description": "The Docker image to deploy."
  108. }
  109. },
  110. "dockerRegistry": {
  111. "type": "string",
  112. "defaultValue": "",
  113. "metadata": {
  114. "description": "The registry of the Docker image."
  115. }
  116. },
  117. "dockerRegistryUserName": {
  118. "type": "string",
  119. "defaultValue": "",
  120. "metadata": {
  121. "description": "The user name for the Docker registry."
  122. }
  123. },
  124. "dockerRegistryPassword": {
  125. "type": "securestring",
  126. "defaultValue": "",
  127. "metadata": {
  128. "description": "The password for the Docker registry."
  129. }
  130. }
  131. },
  132. "variables": {
  133. "location": "[resourceGroup().location]",
  134. "databaseSkuTier": "GeneralPurpose",
  135. "databaseSkuFamily": "Gen5",
  136. "databaseSkuName": "[concat('GP_', variables('databaseSkuFamily'), '_', parameters('databaseCores'))]",
  137. "databaseVersion": "9.6",
  138. "databaseServerPort": 5432,
  139. "databaseServerName": "[concat(parameters('appName'),'-state')]",
  140. "databaseUserCredentials" : "[concat(uriComponent(concat(parameters('adminUserName'), '@', variables('databaseServerName'))), ':', parameters('adminPassword'))]",
  141. "databaseFqdn" : "[concat( variables('databaseServerName'), '.postgres.database.azure.com:', variables('databaseServerPort'))]",
  142. "databaseConnectionString": "[concat('pgsql://', variables('databaseUserCredentials'), '@', variables('databaseFqdn'), '/', parameters('databaseName'))]",
  143. "sendgridAccountName": "[concat(parameters('appName'),'-email')]",
  144. "appServicePlanName": "[concat(parameters('appName'),'-hosting')]",
  145. "analyticsName": "[concat(parameters('appName'),'-analytics')]",
  146. "appFqdn": "[concat(parameters('appName'),'.azurewebsites.net')]"
  147. },
  148. "resources": [
  149. {
  150. "name": "[variables('sendgridAccountName')]",
  151. "type": "Sendgrid.Email/accounts",
  152. "apiVersion": "2015-01-01",
  153. "location": "[variables('location')]",
  154. "plan": {
  155. "name": "[parameters('sendgridSku')]",
  156. "publisher": "Sendgrid",
  157. "product": "sendgrid_azure",
  158. "promotionCode": ""
  159. },
  160. "properties": {
  161. "acceptMarketingEmails": false,
  162. "email": "[parameters('adminContactEmail')]",
  163. "password": "[parameters('adminPassword')]"
  164. }
  165. },
  166. {
  167. "type": "Microsoft.Insights/components",
  168. "apiVersion": "2015-05-01",
  169. "name": "[variables('analyticsName')]",
  170. "location": "[variables('location')]",
  171. "tags": {},
  172. "kind": "web",
  173. "properties": {
  174. "Application_Type": "web"
  175. }
  176. },
  177. {
  178. "apiVersion": "2017-08-01",
  179. "type": "Microsoft.Web/serverfarms",
  180. "kind": "linux",
  181. "name": "[variables('appServicePlanName')]",
  182. "location": "[variables('location')]",
  183. "properties": {
  184. "reserved": true
  185. },
  186. "dependsOn": [],
  187. "sku": {
  188. "name": "[parameters('appServiceSku')]"
  189. }
  190. },
  191. {
  192. "apiVersion": "2017-12-01",
  193. "type": "Microsoft.DBforPostgreSQL/servers",
  194. "location": "[variables('location')]",
  195. "name": "[variables('databaseServerName')]",
  196. "sku": {
  197. "name": "[variables('databaseSkuName')]",
  198. "tier": "[variables('databaseSkuTier')]",
  199. "family": "[variables('databaseSkuFamily')]",
  200. "capacity": "[parameters('databaseCores')]",
  201. "size": "[parameters('databaseSize')]"
  202. },
  203. "properties": {
  204. "version": "[variables('databaseVersion')]",
  205. "administratorLogin": "[parameters('adminUserName')]",
  206. "administratorLoginPassword": "[parameters('adminPassword')]",
  207. "storageMB": "[parameters('databaseSize')]"
  208. },
  209. "resources": [
  210. {
  211. "name": "allowAzure",
  212. "type": "firewallrules",
  213. "apiVersion": "2017-12-01",
  214. "location": "[variables('location')]",
  215. "properties": {
  216. "startIpAddress": "0.0.0.0",
  217. "endIpAddress": "0.0.0.0"
  218. },
  219. "dependsOn": [
  220. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  221. ]
  222. },
  223. {
  224. "name": "[parameters('databaseName')]",
  225. "type": "databases",
  226. "apiVersion": "2017-12-01",
  227. "properties": {
  228. "charset": "utf8",
  229. "collation": "English_United States.1252"
  230. },
  231. "dependsOn": [
  232. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]"
  233. ]
  234. }
  235. ]
  236. },
  237. {
  238. "type": "Microsoft.Web/sites",
  239. "apiVersion": "2016-08-01",
  240. "name": "[parameters('appName')]",
  241. "kind": "app,linux,container",
  242. "location": "[variables('location')]",
  243. "dependsOn": [
  244. "[resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName'))]",
  245. "[resourceId('Microsoft.DBforPostgreSQL/servers/', variables('databaseServerName'))]",
  246. "[resourceId('Microsoft.Insights/components', variables('analyticsName'))]",
  247. "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  248. ],
  249. "properties": {
  250. "name": "[parameters('appName')]",
  251. "siteConfig": {
  252. "linuxFxVersion": "[concat('DOCKER|', parameters('dockerImageName'))]",
  253. "alwaysOn": true,
  254. "appSettings": [
  255. {
  256. "name": "WEBSITES_PORT",
  257. "value": "8000"
  258. },
  259. {
  260. "name": "PORT",
  261. "value": "8000"
  262. },
  263. {
  264. "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
  265. "value": "false"
  266. },
  267. {
  268. "name": "DOCKER_REGISTRY_SERVER_URL",
  269. "value": "[parameters('dockerRegistry')]"
  270. },
  271. {
  272. "name": "DOCKER_REGISTRY_SERVER_USERNAME",
  273. "value": "[parameters('dockerRegistryUserName')]"
  274. },
  275. {
  276. "name": "DOCKER_REGISTRY_SERVER_PASSWORD",
  277. "value": "[parameters('dockerRegistryPassword')]"
  278. },
  279. {
  280. "name": "AZURE_APPINSIGHTS_IKEY",
  281. "value": "[reference(resourceId('Microsoft.Insights/components', variables('analyticsName')), '2014-04-01').InstrumentationKey]"
  282. },
  283. {
  284. "name": "GOOGLE_TRACKING_ID",
  285. "value": " "
  286. },
  287. {
  288. "name": "ADMIN_USERNAME",
  289. "value": "[parameters('adminUserName')]"
  290. },
  291. {
  292. "name": "ADMIN_EMAIL",
  293. "value": "[parameters('adminContactEmail')]"
  294. },
  295. {
  296. "name": "ADMIN_PASSWORD",
  297. "value": "[parameters('adminPassword')]"
  298. },
  299. {
  300. "name": "EMAIL_USE_TLS",
  301. "value": "True"
  302. },
  303. {
  304. "name": "EMAIL_HOST",
  305. "value": "[reference(resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName'))).smtpServer]"
  306. },
  307. {
  308. "name": "EMAIL_HOST_USER",
  309. "value": "[reference(resourceId('Sendgrid.Email/accounts', variables('sendgridAccountName'))).username]"
  310. },
  311. {
  312. "name": "EMAIL_HOST_PASSWORD",
  313. "value": "[parameters('adminPassword')]"
  314. },
  315. {
  316. "name": "EMAIL_PORT",
  317. "value": "587"
  318. },
  319. {
  320. "name": "DEBUG",
  321. "value": "False"
  322. },
  323. {
  324. "name": "SECRET_KEY",
  325. "value": "[parameters('secretKey')]"
  326. },
  327. {
  328. "name": "DATABASE_URL",
  329. "value": "[variables('databaseConnectionString')]"
  330. }
  331. ]
  332. },
  333. "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
  334. }
  335. }
  336. ],
  337. "outputs": {
  338. "appServer": {
  339. "type": "string",
  340. "value": "[concat(variables('appFqdn'))]"
  341. },
  342. "databaseServer": {
  343. "type": "string",
  344. "value": "[variables('databaseFqdn')]"
  345. }
  346. }
  347. }