Repository: microsoft/terminal (language: cpp)

Issue:
Unable to duplicate Azure Cloud Shell Profile
### Windows Terminal version

1.11.3471.0

### Windows build number

10.0.19044.1415

### Other Software

_No response_

### Steps to reproduce

Start Windows Terminal
Go to settings
Add a new profile
Duplicate Azure Cloud Shell Profile & Save


### Expected Behavior

I expect this to work in the same way as it works for PowerShell or Ubuntu. 

### Actual Behavior

It doesn't work and fails with the error below.

[error 0x80070002 when launching `Azure']
![windowsterminal-3](https://user-images.githubusercontent.com/26162427/148645462-e63c8fe7-b02a-4b68-a1f8-3cf2b4160bf9.JPG)
![windowsterminal-2](https://user-images.githubusercontent.com/26162427/148645463-36c97d5b-38af-4e29-9966-77246f81b227.JPG)
![windowsterminal-1](https://user-images.githubusercontent.com/26162427/148645464-e8b1f4de-59ac-45ad-9cf6-f2610275ac17.JPG)




Discussion / hints:
Huh. Out of curiosity, why are you trying to duplicate the azure shell profile? I'm not sure there's any configuration you can do to the shell itself, o it's always going to drop you to the same shell prompt...

This might require more discussion. Duplicating that profile _does_ make sense in the future where we do allow more customization of that prompt, to allow other configs. Maybe we need to include `connectionType` as part of the properties for that profile. If we did that, then that property would get duplicated when we duplicate the profile.
@zadjii-msft I was trying that out of curiosity only. It works for other profiles. 
@blessedwithsins you're not duplicating the profile only. You're changing the command to `Azure` which doesn't exist on your system. `0x80070002` is FILE_NOT_FOUND error. If you have Azure CLI installed, the command is `az` .
That's not strictly true. The Terminal does some behind-the-scenes magic for the azure cloud shell, so it doesn't even really use the `commandline`. However, the profile also does need a valid commandline, so we just slap in `Azure` as the commandline. It's obviously not a valid commandline, but that's by design. So when the profile gets duplicated, that invalid `Azure` commandline gets duplicated as well.

Now, the design just needs to be better to actually allow this to work.
@elsaco This also doesn't work.

![image](https://user-images.githubusercontent.com/26162427/148792684-d9cafc2a-bbf5-4020-a635-a12eb57bf052.png)

I'm seeing different output on my system. This is the duplicated Azure profile:

![azure_duplicate](https://user-images.githubusercontent.com/3933920/148793219-e57a35f6-0424-40e9-a9ef-3d80162d336c.png)

and when launching the duplicated it drops to a CLI prompt:

![azure_shell_copy](https://user-images.githubusercontent.com/3933920/148793348-e49e4eea-4366-477a-a301-74730a965e15.png)

The first `Azure` profile works as expected.

@blessedwithsins I'm using terminal `Version: 1.12.3472.0` the latest preview release. That's probably why the different outputs. 
@elsaco not specific to version. Please try to create a new profile using duplicate option for Azure Cloud Shell. 
This is for sure a bug -- @elasco don't worry that you are seeing something _slightly_ different from @blessedwithsins. It has not actually been addressed.
Oh we just forgot to duplicate `connectionType` this might be easier than we think.

Fix patch:
diff --git a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
index 96ecaa9ac51..858c9f25253 100644
--- a/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
+++ b/src/cascadia/TerminalSettingsModel/CascadiaSettings.cpp
@@ -345,7 +345,13 @@ Model::Profile CascadiaSettings::DuplicateProfile(const Model::Profile& source)
         duplicated->UnfocusedAppearance(*unfocusedAppearance);
     }
 
-    if (source.HasConnectionType())
+    // GH#12120: Check if the connection type isn't just the default value. If
+    // it is, then we should copy it. The only case this applies right now is
+    // for the Azure Cloud Shell, which is the only thing that has a non-{}
+    // guid. The user's version of this profile won't have connectionType set,
+    // because it inherits the setting from the parent. If we fail to copy it
+    // here, they won't actually get a Azure shell profile.
+    if (source.ConnectionType() != winrt::guid{})
     {
         duplicated->ConnectionType(source.ConnectionType());
     }


Test patch: