Provision Backend with Terraform with Docker Container for API already set up

This commit is contained in:
Robin-Manuel Thiel 2018-10-02 20:14:05 +02:00
Родитель ee79601039
Коммит b76bc9c768
4 изменённых файлов: 30 добавлений и 12 удалений

Просмотреть файл

@ -48,6 +48,5 @@ terraform apply
You will need to run the following steps from the main walkthrough to build and deploy the application.
[Deploy App Service](https://github.com/MikeCodesDotNET/Mobile-Cloud-Workshop/tree/master/Walkthrough%20Guide/03%20Web%20API#3-deploy-your-apps-to-app-service)
[Index data in Cosmos](https://github.com/MikeCodesDotNET/Mobile-Cloud-Workshop/tree/master/Walkthrough%20Guide/05%20Search#indexing-our-data)
[Deploy Function](https://github.com/MikeCodesDotNET/Mobile-Cloud-Workshop/tree/master/Walkthrough%20Guide/06%20Functions%20and%20Cognitive%20Services#26-deploy-to-azure)
- [Index data in Cosmos](https://github.com/MikeCodesDotNET/Mobile-Cloud-Workshop/tree/master/Walkthrough%20Guide/05%20Search#indexing-our-data)
- [Deploy Function](https://github.com/MikeCodesDotNET/Mobile-Cloud-Workshop/tree/master/Walkthrough%20Guide/06%20Functions%20and%20Cognitive%20Services#26-deploy-to-azure)

Просмотреть файл

@ -3,17 +3,24 @@ resource "azurerm_app_service_plan" "workshop" {
location = "${azurerm_resource_group.workshop.location}"
resource_group_name = "${azurerm_resource_group.workshop.name}"
# Define Linux as Host OS
kind = "Linux"
sku {
tier = "Standard"
size = "S1"
}
properties {
reserved = true # Mandatory for Linux plans
}
}
resource "azurerm_app_service" "workshop" {
name = "${var.resource_name}${random_id.workshop.dec}"
location = "${azurerm_resource_group.workshop.location}"
resource_group_name = "${azurerm_resource_group.workshop.name}"
app_service_plan_id = "${azurerm_app_service_plan.workshop.id}"
name = "${var.resource_name}${random_id.workshop.dec}"
location = "${azurerm_resource_group.workshop.location}"
resource_group_name = "${azurerm_resource_group.workshop.name}"
app_service_plan_id = "${azurerm_app_service_plan.workshop.id}"
app_settings {
APPINSIGHTS_INSTRUMENTATIONKEY = "${azurerm_application_insights.workshop.instrumentation_key}"
@ -23,6 +30,14 @@ resource "azurerm_app_service" "workshop" {
AzureStorage__StorageAccountName = "${azurerm_storage_account.workshop.name}"
AzureStorage__Key = "${azurerm_storage_account.workshop.primary_access_key}"
WEBSITES_ENABLE_APP_SERVICE_STORAGE = false
}
# Configure Docker Image to load on start
site_config {
linux_fx_version = "DOCKER|robinmanuelthiel/contosomaintenance-api:latest"
always_on = "true"
}
identity {

Просмотреть файл

@ -1,3 +1,7 @@
# We are using Docker for the Web App, so we have to use Linux
# as Functions host. Currently, Consumption Plan for Azure Functions
# is only in preview, so we host the Function on the Same App Service Plan as the API
/*
resource "azurerm_app_service_plan" "func" {
name = "azure-functions-${var.resource_name}-service-plan"
location = "${azurerm_resource_group.workshop.location}"
@ -8,13 +12,13 @@ resource "azurerm_app_service_plan" "func" {
tier = "Dynamic"
size = "Y1"
}
}
}*/
resource "azurerm_function_app" "workshop" {
name = "func-${var.resource_name}${random_id.workshop.dec}"
location = "${azurerm_resource_group.workshop.location}"
resource_group_name = "${azurerm_resource_group.workshop.name}"
app_service_plan_id = "${azurerm_app_service_plan.func.id}"
app_service_plan_id = "${azurerm_app_service_plan.workshop.id}"
storage_connection_string = "${azurerm_storage_account.workshop.primary_connection_string}"
# looks like at the moment for v2 http version has to be http1.1 and app has to be 32bit
@ -22,11 +26,11 @@ resource "azurerm_function_app" "workshop" {
app_settings {
APPINSIGHTS_INSTRUMENTATIONKEY = "${azurerm_application_insights.workshop.instrumentation_key}"
CosmosDB = "AccountEndpoint=${azurerm_cosmosdb_account.workshop.endpoint};AccountKey=${azurerm_cosmosdb_account.workshop.primary_master_key};"
CognitiveServicesEndpoint = "${azurerm_template_deployment.workshop.outputs["vision_endpoint"]}"
CognitiveServicesKey = "${azurerm_template_deployment.workshop.outputs["vision_key"]}"
CognitiveServicesKey = "${azurerm_template_deployment.workshop.outputs["vision_key"]}"
}
identity {

Просмотреть файл

@ -1,5 +1,5 @@
provider "azurerm" {
version = "~> 1.14"
version = "~> 1.15"
}
provider "random" {