Hello! Has anyone managed to build a container ima...
# azure
s
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
Uhm, isn’t the docker provider using the local docker build?
t
It does. What’s your scenario?
s
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
Copy code
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
Sounds like https://github.com/pulumi/pulumi-azure-native/issues/736 Are you on the latest version?
s
Yes, I am using 1.1.0 but I am not specifying the identity. I will try adding that
t
This doesn’t sound like an identity problem. Could you share your code?
s
Copy code
_, 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:
Copy code
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
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
Thank you for the help. Could it be the Credentials block missing? The body looks correct
t
I haven’t used that resource so I can’t tell
👍 1
s
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
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.)