https://pulumi.com logo
Title
s

steep-beard-51215

04/22/2021, 2:51 PM
Hello! Has anyone managed to build a container image using azure-native provider?
(building an image is done by the Docker provider, I assumed you need to put it to Azure Container Registry)
s

steep-beard-51215

04/22/2021, 2:54 PM
Uhm, isn’t the docker provider using the local docker build?
t

tall-librarian-49374

04/22/2021, 2:54 PM
It does. What’s your scenario?
s

steep-beard-51215

04/22/2021, 2:54 PM
I would actually use ACR to build and push. Basically the same as
az acr build
I am trying to use
containerregistry.TaskRun
but the output is
azure-native:containerregistry:TaskRun (container-build):
    error: Code="InvalidRequestBody" Message="The request body is required for this request. Check if the body is not empty. If the request expects a polymorphic type, check if it has the discriminator property and is one of the described values." Target="request"
t

tall-librarian-49374

04/22/2021, 2:57 PM
Sounds like https://github.com/pulumi/pulumi-azure-native/issues/736 Are you on the latest version?
s

steep-beard-51215

04/22/2021, 2:58 PM
Yes, I am using 1.1.0 but I am not specifying the identity. I will try adding that
t

tall-librarian-49374

04/22/2021, 3:00 PM
This doesn’t sound like an identity problem. Could you share your code?
s

steep-beard-51215

04/22/2021, 3:01 PM
_, err = cr.NewTaskRun(ctx, "container-build", &cr.TaskRunArgs{
			RegistryName:      registry.Name,
			ResourceGroupName: rg.Name,
			Location:          registry.Location,
			RunRequest: cr.DockerBuildRequestArgs{
				Target:         pulumi.String("request"),
				DockerFilePath: pulumi.String("build/package"),
				IsPushEnabled:  pulumi.Bool(true),
				LogTemplate:    pulumi.String("acr/tasks:{{.Run.OS}}"),
				Platform: &cr.PlatformPropertiesArgs{
					Os: cr.OSLinux,
				},
				Arguments: cr.ArgumentArray{
					cr.ArgumentArgs{
						Name:  pulumi.String("ADOPTOPENJDK_VERSION"),
						Value: pulumi.String("11-openj9"),
					},
				},
				ImageNames: imageNames,
			},
		})
BTW, there is a catch in the GO sdk:
Identity: cr.IdentityPropertiesArgs{
				Type: &cr.ResourceIdentityTypeSystemAssigned,
			},
The Type is specified as a pointer but
ResourceIdentityTypeSystemAssigned
is a const. It’s not possible to pass the reference using
&
. We need to declare a variable
something := cr.ResourceIdentityTypeSystemAssigned
and then use
Type: &something
t

tall-librarian-49374

04/22/2021, 3:16 PM
yeah, FWIW, that’s typical for our Go SDK
👍 1
Could you log the request as described below and share the body? https://github.com/pulumi/pulumi-azure-native/issues/736#issuecomment-817734560
Feel free to open an issue if you think something goes wrong there
s

steep-beard-51215

04/22/2021, 3:27 PM
Thank you for the help. Could it be the Credentials block missing? The body looks correct
t

tall-librarian-49374

04/22/2021, 3:28 PM
I haven’t used that resource so I can’t tell
👍 1
s

steep-beard-51215

04/22/2021, 3:29 PM
I will try adding the credentials. I only need to figure out how to
ApplyT
from
string
to
map[string]cr.CustomRegistryCredentialsInput
registry.LoginServer.ApplyT(customRegistryCredentialsApplyFn).(cr.CustomRegistryCredentialsMapOutput)
panics (the function returns the raw map)
@tall-librarian-49374 found the error. It needs the
Type: pulumi.String("DockerBuildRequest")
which is missing in the documentation
It fails anyway, but with another error about the context this time 🙂
t

tall-librarian-49374

04/22/2021, 6:42 PM
Aha… Do you mind opening an issue about the missing doc property?
👍 1
👀 1
(I thought we would set it automatically, as e.g. the .NET SDK does. Maybe that’s the issue.)