hashicorp / packer-plugin-azure

Packer plugin for Azure Virtual Machine Image Builders
https://www.packer.io/docs/builders/azure
Mozilla Public License 2.0
47 stars 76 forks source link

Update to the newest version of hashicorp/go-azure-sdk #396

Closed JenGoldstrich closed 3 months ago

JenGoldstrich commented 3 months ago

This PR makes several changes to upgrade github.com/hashicorp/go-azure-sdk from version v0.20230523.1140858 to the newest version at the time of this PR v0.20240327.1161949, and to fully remove the deprecated Microsoft go-autorest library.

  1. Every request on the new SDK client layer requires a context with a deadline, otherwise requests fail with the following error the context used must have a deadline attached for polling purposes, but got no deadline, even if counter-intuitively the request would not use polling

  2. When the tenant ID is unset and not using CLI auth the plugin makes an unauthenticated HTTP request to the GetSubscriptions endpoint to fetch the tenant ID through the auth headers, the new SDK does not return these headers unless the auth object is correctly configured so now this is done with a regular http client

  3. The Chroot Builder used an autorest client to connect to the Azure IMDS, this has also been modified to use a regular http client, enabling the removal of auto rest

  4. The chroot builder has a long running bug https://github.com/hashicorp/packer-plugin-azure/issues/87 where we get an error that the vm template function is not defined unless setting 4 temporary values, this is due to an issue with the packer SDK wiping out this function when calling Decode, @lbajolet-hashicorp is investigating this issue further on the SDK end but to fix this on chroot this PR moves the function after Decode, so that is available in the builder. The vm function does not appear to be working at all currently, but this seems due to the SDK bug, and will be addressed in a follow up PR if not.

Closes https://github.com/hashicorp/packer-plugin-azure/issues/87 Unblocks https://github.com/hashicorp/packer-plugin-azure/issues/395