diff --git a/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/main/java/com/azure/resourcemanager/containerinstance/implementation/ContainerGroupImpl.java b/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/main/java/com/azure/resourcemanager/containerinstance/implementation/ContainerGroupImpl.java index d358c1d2029c5..4a049e47b9b22 100644 --- a/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/main/java/com/azure/resourcemanager/containerinstance/implementation/ContainerGroupImpl.java +++ b/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/main/java/com/azure/resourcemanager/containerinstance/implementation/ContainerGroupImpl.java @@ -19,6 +19,8 @@ import com.azure.resourcemanager.containerinstance.models.ContainerGroupNetworkProtocol; import com.azure.resourcemanager.containerinstance.models.ContainerGroupRestartPolicy; import com.azure.resourcemanager.containerinstance.models.ContainerGroupSubnetId; +import com.azure.resourcemanager.containerinstance.models.ContainerNetworkProtocol; +import com.azure.resourcemanager.containerinstance.models.ContainerPort; import com.azure.resourcemanager.containerinstance.models.DnsConfiguration; import com.azure.resourcemanager.containerinstance.models.Event; import com.azure.resourcemanager.containerinstance.models.ImageRegistryCredential; @@ -189,6 +191,13 @@ protected void initializeChildrenFromInner() { if (this.innerModel().containers() != null && this.innerModel().containers().size() > 0) { for (Container containerInstance : this.innerModel().containers()) { this.containers.put(containerInstance.name(), containerInstance); + if (containerInstance.ports() != null) { + for (ContainerPort port : containerInstance.ports()) { + if (port.protocol() == null) { + port.withProtocol(ContainerNetworkProtocol.TCP); + } + } + } } } @@ -214,6 +223,9 @@ protected void initializeChildrenFromInner() { List tcpPorts = new ArrayList<>(); List udpPorts = new ArrayList<>(); for (Port port : this.innerModel().ipAddress().ports()) { + if (port.protocol() == null) { + port.withProtocol(ContainerGroupNetworkProtocol.TCP); + } if (port.protocol().equals(ContainerGroupNetworkProtocol.TCP)) { tcpPorts.add(port); } else if (port.protocol().equals(ContainerGroupNetworkProtocol.UDP)) {