diff --git a/builder/azure/arm/artifact.go b/builder/azure/arm/artifact.go index 25672c6f2..5de9f90e1 100644 --- a/builder/azure/arm/artifact.go +++ b/builder/azure/arm/artifact.go @@ -86,8 +86,8 @@ func (*Artifact) Files() []string { return []string{} } -func (*Artifact) Id() string { - return "" +func (a *Artifact) Id() string { + return a.OSDiskUri } func (a *Artifact) State(name string) interface{} { diff --git a/builder/azure/arm/artifact_test.go b/builder/azure/arm/artifact_test.go index e7900ff53..7202b6529 100644 --- a/builder/azure/arm/artifact_test.go +++ b/builder/azure/arm/artifact_test.go @@ -13,6 +13,37 @@ func getFakeSasUrl(name string) string { return fmt.Sprintf("SAS-%s", name) } +func TestArtifactId(t *testing.T) { + template := CaptureTemplate{ + Resources: []CaptureResources{ + { + Properties: CaptureProperties{ + StorageProfile: CaptureStorageProfile{ + OSDisk: CaptureDisk{ + Image: CaptureUri{ + Uri: "https://storage.blob.core.windows.net/system/Microsoft.Compute/Images/images/packer-osDisk.4085bb15-3644-4641-b9cd-f575918640b4.vhd", + }, + }, + }, + }, + Location: "southcentralus", + }, + }, + } + + artifact, err := NewArtifact(&template, getFakeSasUrl) + if err != nil { + t.Fatalf("err=%s", err) + } + + expected := "https://storage.blob.core.windows.net/system/Microsoft.Compute/Images/images/packer-osDisk.4085bb15-3644-4641-b9cd-f575918640b4.vhd" + + result := artifact.Id() + if result != expected { + t.Fatalf("bad: %s", result) + } +} + func TestArtifactString(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{