pulumi / examples

Infrastructure, containers, and serverless apps to AWS, Azure, GCP, and Kubernetes... all deployed with Pulumi
https://www.pulumi.com
Apache License 2.0
2.39k stars 879 forks source link

Ensure better Azure Container Apps integration with Pulumi IaC #1247

Open ezYakaEagle442 opened 2 years ago

ezYakaEagle442 commented 2 years ago

Hello!

Issue details

Pulumi docs does not show how to provision Azure Container App with latest features such as deployment to VNet.

Read https://github.com/pulumi/examples/blob/master/azure-ts-containerapps/index.ts try to deploy 1 Azure Container App with all latest features including deployment to VNet, AuthConfigs, Probes, Scaling rules, volumes, etc.

Here are some repos that provision Azure Container Apps using Azure Bicep IaC :

Affected area/feature

See also https://github.com/microsoft/azure-container-apps/issues/288

Zaid-Ajaj commented 2 years ago

Hi @ezYakaEagle442 thanks for filing the issue! We have moved it to pulumi/examples repo since it is more about adding docs and not something that is particularly missing in the Pulumi CLI or the SDKs. If that is the case, please let us know and we will try to resolve the issue as soon as possible

joaocpribeiro commented 9 months ago

@jkodroff @Zaid-Ajaj I am trying to add a azure-files volume to my app container. As far as I can see, this feature is missing. There is no azurefiles option for volumes (also here). Thinking that it could be a documentation issue, and trying out code provided by pulumi-ai, errors appear. Am I missing something?

joaocpribeiro commented 9 months ago

I was mistaken, the feature exists. But the documentation is missing, indeed. I share my solution, which can help others arriving to this thread. Sorry for the identation.

    const storageAccountKeys = listStorageAccountKeys({
        resourceGroupName,
        accountName, // Storage account name.
      });

    const managedEnvironmentsStorage = new ManagedEnvironmentsStorage(`myManagedEnvironmentsStorage`, {
      environmentName: containerEnvResult.name, // Name of Container Apps Environment.
      properties: {
        azureFile: {
          accessMode: "ReadWrite",
          accountKey: storageAccountKeys.keys[0].value,
          accountName: accountName, // Storage account name.
          shareName: fileShareName, // The name of the Azure Files in storage account.
        },
      },
      resourceGroupName: resourceGroupName,
      storageName: `mymanagedenvstorage`,
    });

  let volumeName = `myvolume`;
  const containerApp = new ContainerApp(
    `myContainerApp`,
    {
      (...),
      template: {
        containers: [
          {
            (...)
            volumeMounts: [{
              mountPath: pathToPersistInVolume, // Path within your container app, where the volume will be mounted.
              subPath: '',
              volumeName: volumeName
            }],
          },
        ],
        (...)
        volumes: [{
          name: volumeName,
          storageType: "AzureFile",
          storageName: managedEnvironmentsStorage.name
        }],
      },
      (...)
    }
  );

Note that several names need to be lowercase, but pulumi will inform you if they are not.

isaac-pulumi commented 9 months ago

@joaocpribeiro thank you for the update. I've added @interurban to the issue for details on missing documentation for this feature.