Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Web App for Containers support #580

Closed
mojodna opened this issue Nov 21, 2017 · 15 comments · Fixed by #1578
Closed

Feature Request: Web App for Containers support #580

mojodna opened this issue Nov 21, 2017 · 15 comments · Fixed by #1578
Labels
enhancement service/app-service upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR

Comments

@mojodna
Copy link

mojodna commented Nov 21, 2017

Terraform version:

Terraform v0.11.0
+ provider.azurerm v0.3.3
+ provider.random v1.0.0

I'd like to automate deployment of Docker containers as Web Apps to a Linux App Service Plan, i.e. using the equivalent of az webapp create ... --deployment-container-image-name <image URL>.

@mojodna mojodna changed the title Web App for Containers support Feature Request: Web App for Containers support Dec 1, 2017
@tombuildsstuff
Copy link
Contributor

tombuildsstuff commented Dec 4, 2017

Hey @mojodna

Thanks for opening this issue :)

Taking a quick look into this issue - this appears to be a regular App Service with the linuxFxVersion field within the site configuration set to DOCKER|(container name + optional version) (e.g. DOCKER|golang or DOCKER|golang:latest); and an app setting of WEBSITES_ENABLE_APP_SERVICE_STORAGE = false.

We don't support this field right now due to a bug in the Azure App Service API - that said once the bug in the API is fixed we can take a look into supporting this functionality. Until then, you should be able to achieve the same thing with the azurerm_template_deployment resource.

Thanks!

@mojodna
Copy link
Author

mojodna commented Dec 5, 2017

thanks @tombuildsstuff!

@mojodna
Copy link
Author

mojodna commented Feb 14, 2018

I picked this back up today and haven't been having any luck getting it to work (and can't find any relevant docs). Here's my template:

resource "azurerm_template_deployment" "test" {
  name = "template-01"
  resource_group_name = "${azurerm_resource_group.rg.name}"

  template_body = <<DEPLOY
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "app_service_plan_id": {
      "type": "string",
      "metadata": {
        "description": "App Service Plan ID"
      }
    },
    "name": {
      "type": "string",
      "metadata": {
        "description": "App Name"
      }
    },
    "image": {
      "type": "string",
      "metadata": {
        "description": "Docker image"
      }
    }
  },
  "variables": {
  },
  "resources": [
    {
      "type": "Microsoft.Web/sites",
      "kind": "app,linux,container",
      "name": "[parameters('name')]",
      "properties": {
        "siteConfig": {
          "appSettings": [
            {
              "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
              "value": "false"
            }
          ],
          "linuxFxVersion": "[concat('DOCKER|', parameters('image'))]"
        },
        "name": "[parameters('name')]",
        "serverFarmId": "[parameters('app_service_plan_id')]"
      },
      "apiVersion": "2016-08-01",
      "location": "[resourceGroup().location]"
    }
  ]
}
DEPLOY

  parameters {
    name = "golang"
    image = "golang"
    app_service_plan_id = "${azurerm_app_service_plan.plan.id}"
 }

  deployment_mode = "Incremental"
}

Things generally look like they're created properly, but Azure isn't picking it up as a Docker app for some reason.

Help?

@szinck1
Copy link

szinck1 commented Feb 16, 2018

+1 I'd also like to be able to use terraform to deploy to Web Apps for Containers.

@mojodna
Copy link
Author

mojodna commented Feb 16, 2018

This is the template I used that worked. The difference is "alwaysOn": true within siteConfig:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "app_service_plan_id": {
      "type": "string",
      "metadata": {
        "description": "App Service Plan ID"
      }
    },
    "name": {
      "type": "string",
      "metadata": {
        "description": "App Name"
      }
    },
    "image": {
      "type": "string",
      "metadata": {
        "description": "Docker image"
      }
    }
  },
  "resources": [
    {
      "apiVersion": "2016-08-01",
      "kind": "app,linux,container",
      "name": "[parameters('name')]",
      "type": "Microsoft.Web/sites",
      "properties": {
        "name": "[parameters('name')]",
        "siteConfig": {
          "alwaysOn": true,
          "appSettings": [
            {
              "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
              "value": "false"
            }
          ],
          "linuxFxVersion": "[concat('DOCKER|', parameters('image'))]"
        },
        "serverFarmId": "[parameters('app_service_plan_id')]"
      },
      "location": "[resourceGroup().location]"
    }
  ]
}

@1arrow
Copy link

1arrow commented Apr 21, 2018

+1

@katbyte katbyte added upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR and removed upstream labels May 18, 2018
@maurivg28
Copy link

I have a one question, how do you add code to point image a private registry? For example, I need to deploy a web app for container and to point this web app to Azure Container Registry.

Thanks.

@japais
Copy link

japais commented May 23, 2018

Hey @maurivg28
Try adding to @mojodna 's code the following appSettings:

       {
          "name": "DOCKER_REGISTRY_SERVER_URL",              
          "value": "[parameters('registryURL')]"
        },
        {
          "name": "DOCKER_REGISTRY_SERVER_USERNAME",              
          "value": "[parameters('registryLoginName')]"
        },

        {
          "name": "DOCKER_REGISTRY_SERVER_PASSWORD",
          "value": "[parameters('registryPassword')]"
        }

That will configure a private registry for the image.

Cheers,
J.-

@straubt1
Copy link

+1

@ndarilek
Copy link

Thanks for this, I'm trying to set this up as well. How do I go from the template as shown above, to an actual deployed Docker container that I can load balance to? Does the template provide everything I need, or do I need to reference it from another resource that actually instantiates it?

@ndarilek
Copy link

I'm struggling to make this work. It creates the web app and I can visit mysubdomain.azurewebsites.net, but I just get a landing page with a link to the portal.

One thing missing from these templates is the ability to specify a port for the Docker image. How is this handled? I tried:

          "appSettings": [
            {
              "name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
              "value": "false"
            },
            {
              "name": "WEBSITES_PORT",
              "value": "1337"
            }
          ],

And my Docker image, when pulled locally, successfully responds on that port. But since I'm getting a default landing page, I'm beginning to suspect that maybe I'm not setting up the port mapping correctly.

Thanks for any help. I wish I wasn't stuck with Azure's complexity, but I hope I can use Terraform to successfully wrangle it.

@ndarilek
Copy link

This looks great, thanks! When is the next release? I could never get the templates in this issue working despite the fact that I successfully created a container instance via the command line. Unfortunately, command line export of the resulting ARM templates fails, I'm a screen reader user, and the Azure portal and instructions are inaccessible enough that I can't independently follow them. So I pretty much need a text-based configuration format to automate setting this up, and am a bit blocked by not having this in a release. I can certainly wait a few days, I'm just trying to get a rough idea when I might expect to see it out.

Thanks again.

@tombuildsstuff
Copy link
Contributor

@ndarilek we don’t generally commit to dates for releases, but I have a feeling we’ll be doing a release later this week :)

@rifaterdemsahin
Copy link

what is the status on this one ?

@tombuildsstuff
Copy link
Contributor

Support for this shipped in v1.10 of the AzureRM Provider a few weeks back; you can update to this by updating your Provider block and re-running terraform init:

provider "azurerm" {
  version = "=1.12.0"
}

@hashicorp hashicorp locked and limited conversation to collaborators Aug 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement service/app-service upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants