Hi, since I was already helped very quickly and su...
# general
m
Hi, since I was already helped very quickly and super last time, I wanted to ask if anyone has ever built an Azure webapp with a Docker image using Pulumi SaaS. So my docker image is already ready in our private github docker registry. Basically, all I want to do is to poll it and then pass it to Azure in the WebApp. What I found I the RemoteImage class in the package @pulumi/docker. But unfortunately this doesn't provide any way to authenticate for a private registry. I am looking forward to helpful tips! Thanks already.
b
Just so I’m understanding, you want to deploy to azure app service?
@mysterious-piano-88140
m
Yes I want to deploy a docker image to azure app services
b
take a look here: https://github.com/pulumi/examples/blob/258d3bad0a00020704743e37911c51be63c06bb4/azure-ts-appservice-docker/index.ts#L75-L104 notice, you set the username and password for the private registry as settings. You can set them as secrets in your config is desired, with
pulumi config set adminPassword --secret
m
I already tried this example, but it threw an error on the linuxFxVersion key that the Docker image (
myImage.imageName
) is not known. And on the other hand, it builds the Docker image which is already built in the Docker registry, because a Github action automatically takes care of that.
b
can you share the code you tried?
m
I send the code tomorrow (Germany).
@billowy-army-68599 Here is the code:
Copy code
const servicePlan = new AppServicePlan('appserivceplan', {
      kind: 'Linux',
      name: 'appserviceplan',
      resourceGroupName: 'resourcegroup',
      location: 'germanywestcentral',
      sku: {
        capacity: 2,
        family: 'S2',
        name: 'S2',
        size: 'S2',
        tier: 'Standard'
      },
      tags: {
        env: 'dev',
        type: 'appserviceplan'
      }
    })


    const customImage = 'imagename'
    const registry = '<http://ghcr.io|ghcr.io>'
    const adminUsername = 'username'
    const adminPassword = 'password'

    const myImage = new Image(customImage, {
      build: '../',
      imageName: interpolate`<http://ghcr.io/<organisation>/${customImage}:1.0.0|ghcr.io/<organisation>/${customImage}:1.0.0>`,
      registry: {
        server: registry,
        username: adminUsername,
        password: adminPassword
      }
    })
  
    const app = new WebApp('webapp', {
      kind: 'Linux',
      name: 'webapp',
      resourceGroupName: 'resourcegroup',
      serverFarmId: servicePlan.id,
      siteConfig: {
        appSettings: [
          {
            name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE',
            value: 'false'
          },
          {
            name: 'DOCKER_REGISTRY_SERVER_URL',
            value: interpolate`https://${registry}`
          },
          {
            name: 'DOCKER_REGISTRY_SERVER_USERNAME',
            value: adminUsername
          },
          {
            name: 'DOCKER_REGISTRY_SERVER_PASSWORD',
            value: adminPassword
          },
          {
            name: 'WEBSITES_PORT',
            value: '80' // Our custom image exposes port 80. Adjust for your app as needed.
          }
        ],
        alwaysOn: true,
        linuxFxVersion: interpolate`DOCKER|<http://ghcr.io/<organisation>/${customImage}:1.0.0|ghcr.io/<organisation>/${customImage}:1.0.0>`
      },
      httpsOnly: true
    })
b
I'm not sure you need to interpolate the image name, it's known ahead of time
the error you mentioned earlier said
myImage.imageName
is not known, but I don't see that used anywhere
p
why do you even create
myImage
? I don’t think it is needed in your case. As you say, the image is already build - then you only have to reference it in
linuxFxVersion
and set the correct
DOCKER_REGISTRY_SERVER_URL
,
DOCKER_REGISTRY_SERVER_USERNAME
and
DOCKER_REGISTRY_SERVER_PASSWORD
.