@@ -629,6 +629,10 @@ public AzureVMDeploymentInfo createDeployment(
629629 if (template .isSpotInstance ()) {
630630 addSpotInstance (tmp );
631631 }
632+
633+ if (template .isTrustedLaunch ()) {
634+ addTrustedLaunch (tmp );
635+ }
632636
633637 if (!(Boolean ) properties .get ("usePrivateIP" )) {
634638 addPublicIPResourceNode (tmp , tags );
@@ -739,6 +743,44 @@ private void addSpotInstance(JsonNode template) {
739743 }
740744 }
741745 }
746+
747+
748+ private void addTrustedLaunch (JsonNode template ) {
749+ ObjectNode parameterNode = (ObjectNode ) template .get ("parameters" );
750+ ObjectNode securityTypeNode = MAPPER .createObjectNode ();
751+ securityTypeNode .put ("type" , "string" );
752+ securityTypeNode .put ("defaultValue" , "TrustedLaunch" );
753+ ArrayNode allowedValuesNode = MAPPER .createArrayNode ();
754+ allowedValuesNode .add ("Standard" );
755+ allowedValuesNode .add ("TrustedLaunch" );
756+ securityTypeNode .set ("allowedValues" , allowedValuesNode );
757+ ObjectNode metaDataNode = MAPPER .createObjectNode ();
758+ metaDataNode .put ("description" , "Security Type of the Virtual Machine." );
759+ securityTypeNode .set ("metadata" , metaDataNode );
760+ parameterNode .set ("securityType" , securityTypeNode );
761+
762+ ObjectNode variableNode = (ObjectNode ) template .get ("variables" );
763+ ObjectNode profileNode = MAPPER .createObjectNode ();
764+ ObjectNode settingsNode = MAPPER .createObjectNode ();
765+ settingsNode .put ("secureBootEnabled" , true );
766+ settingsNode .put ("vTpmEnabled" , true );
767+
768+ profileNode .set ("uefiSettings" , settingsNode );
769+ profileNode .put ("securityType" , "[parameters('securityType')]" );
770+
771+ variableNode .set ("securityProfileJson" , profileNode );
772+
773+
774+
775+ ArrayNode resources = (ArrayNode ) template .get ("resources" );
776+ for (JsonNode resource : resources ) {
777+ String type = resource .get ("type" ).asText ();
778+ if (type .contains ("virtualMachine" )) {
779+ ObjectNode properties = (ObjectNode ) resource .get ("properties" );
780+ properties .put ("securityProfile" , "[if(equals(parameters('securityType'), 'TrustedLaunch'), variables('securityProfileJson'), null())]" );
781+ }
782+ }
783+ }
742784
743785 private void addAcceleratedNetworking (JsonNode template ) {
744786 ArrayNode resources = (ArrayNode ) template .get ("resources" );
0 commit comments