Skip to content

Commit 3b16f04

Browse files
bubbletroublessreallymatt
authored andcommitted
Update express_route_port_resource.go
1 parent 80eae45 commit 3b16f04

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

internal/services/network/express_route_port_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package network
66
import (
77
"fmt"
88
"log"
9+
"strings"
910
"time"
1011

1112
"github.com/hashicorp/go-azure-helpers/lang/pointer"
@@ -267,6 +268,24 @@ func resourceArmExpressRoutePortUpdate(d *pluginsdk.ResourceData, meta interface
267268

268269
payload := existing.Model
269270

271+
// Normalize the identity type - Azure API returns lowercase (e.g. "userAssigned")
272+
// but the SDK MarshalJSON expects exact case match (e.g. "UserAssigned")
273+
// Without normalization, MarshalJSON defaults to "None" and removes the identity
274+
if payload.Identity != nil {
275+
// Use string comparison to normalize the type
276+
switch strings.ToLower(string(payload.Identity.Type)) {
277+
case "systemassigned":
278+
payload.Identity.Type = identity.TypeSystemAssigned
279+
case "userassigned":
280+
payload.Identity.Type = identity.TypeUserAssigned
281+
case "systemassigned, userassigned", "systemassigned,userassigned":
282+
payload.Identity.Type = identity.TypeSystemAssignedUserAssigned
283+
case "none":
284+
payload.Identity.Type = identity.TypeNone
285+
}
286+
log.Printf("[DEBUG] Normalized identity type from %q to %q", existing.Model.Identity.Type, payload.Identity.Type)
287+
}
288+
270289
if d.HasChange("identity") {
271290
expandedIdentity, err := identity.ExpandSystemAndUserAssignedMap(d.Get("identity").([]interface{}))
272291
if err != nil {

0 commit comments

Comments
 (0)