diff --git a/builder/azure/arm/azure_client.go b/builder/azure/arm/azure_client.go index 1b81ec2f5..ab4330e37 100644 --- a/builder/azure/arm/azure_client.go +++ b/builder/azure/arm/azure_client.go @@ -9,6 +9,7 @@ import ( "net/url" "os" "strconv" + "time" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute" newCompute "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute" @@ -126,7 +127,7 @@ func byConcatDecorators(decorators ...autorest.RespondDecorator) autorest.Respon } func NewAzureClient(subscriptionID, resourceGroupName, storageAccountName string, - cloud *azure.Environment, + cloud *azure.Environment, SharedGalleryTimeout time.Duration, servicePrincipalToken, servicePrincipalTokenVault *adal.ServicePrincipalToken) (*AzureClient, error) { var azureClient = &AzureClient{} @@ -210,6 +211,7 @@ func NewAzureClient(subscriptionID, resourceGroupName, storageAccountName string azureClient.GalleryImageVersionsClient.RequestInspector = withInspection(maxlen) azureClient.GalleryImageVersionsClient.ResponseInspector = byConcatDecorators(byInspecting(maxlen), errorCapture(azureClient)) azureClient.GalleryImageVersionsClient.UserAgent = fmt.Sprintf("%s %s", useragent.String(), azureClient.GalleryImageVersionsClient.UserAgent) + azureClient.GalleryImageVersionsClient.Client.PollingDuration = SharedGalleryTimeout azureClient.GalleryImagesClient = newCompute.NewGalleryImagesClientWithBaseURI(cloud.ResourceManagerEndpoint, subscriptionID) azureClient.GalleryImagesClient.Authorizer = autorest.NewBearerAuthorizer(servicePrincipalToken) diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index 7b64e0b15..2be58819d 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -90,6 +90,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.config.ResourceGroupName, b.config.StorageAccount, b.config.cloudEnvironment, + b.config.SharedGalleryTimeout, spnCloud, spnKeyVault) diff --git a/builder/azure/arm/config.go b/builder/azure/arm/config.go index af34754dc..5e9b8905c 100644 --- a/builder/azure/arm/config.go +++ b/builder/azure/arm/config.go @@ -96,6 +96,7 @@ type Config struct { // Shared Gallery Destination SharedGalleryDestination SharedImageGalleryDestination `mapstructure:"shared_image_gallery_destination"` + SharedGalleryTimeout time.Duration `mapstructure:"shared_image_gallery_timeout"` // Compute ImagePublisher string `mapstructure:"image_publisher"` @@ -648,6 +649,10 @@ func assertRequiredParametersSet(c *Config, errs *packer.MultiError) { errs = packer.MultiErrorAppend(errs, fmt.Errorf("A list of replication_regions must be specified for shared_image_gallery_destination")) } } + if c.SharedGalleryTimeout == 0 { + // default to a one-hour timeout. In the sdk, the default is 15 m. + c.SharedGalleryTimeout = 60 * time.Minute + } if c.ManagedImageOSDiskSnapshotName != "" { if ok, err := assertManagedImageOSDiskSnapshotName(c.ManagedImageOSDiskSnapshotName, "managed_image_os_disk_snapshot_name"); !ok {