Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Azure cloud shell connector #1808

Merged
merged 21 commits into from
Jul 25, 2019

Conversation

PankajBhojwani
Copy link
Contributor

Implemented a new connection type, the Azure cloud shell connector

#1235

PR Checklist

  • Closes Feature Request: Azure cloud shell connector #1235
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan.
  • Implemented a new connection
  • Created a new default profile for that connection (includes icons)
  • Added very basic handling for the backspace VT sequence
  • Added a condition to check for \a (aka the BEL character) just so we don't try to print that character

@PankajBhojwani PankajBhojwani changed the title The Azure cloud shell connector is here! The Azure cloud shell connector Jul 3, 2019
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we will want to find a solution that doesn't require us to commit the entire VCPKG nuget package into the repository since it's 50+MB.

src/cascadia/TerminalApp/App.cpp Outdated Show resolved Hide resolved
// Create a Conhost connection based on the values in our settings object.
TerminalConnection::ITerminalConnection controlConnection = TerminalConnection::ConhostConnection(controlSettings.Commandline(), controlSettings.StartingDirectory(), 30, 80, winrt::guid());
TerminalConnection::ITerminalConnection controlConnection{ nullptr };
if (controlSettings.Commandline() == L"Azure")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic string L"Azure" is used in multiple places. It should be defined once as a constant imported into all useful locations.

(This will still be applicable if you change it to an enum or guid)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we will want to find a solution that doesn't require us to commit the entire VCPKG nuget package into the repository since it's 50+MB.

I recently discovered I had to use vcpkg to install cpprestsdk:x64-windows.

One solution would be to move away from submodules to git subtrees.
https://blog.developer.atlassian.com/the-power-of-git-subtree/

This would reduce the burden of a submodule which by default pulls in the entire repo (and its history).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love subtrees, but.. we're not using submodules for cpprest or anything vcpkg-related.

src/cascadia/TerminalApp/App.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalConnection/packages.config Outdated Show resolved Hide resolved
src/cascadia/TerminalConnection/pch.h Outdated Show resolved Hide resolved
src/cascadia/TerminalCore/TerminalDispatch.cpp Outdated Show resolved Hide resolved
@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Jul 5, 2019
@ras0219-msft
Copy link

Creating a public Azure DevOps Artifacts Feed may be a better option than checking in the NuGet packages.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Michael has a bunch of other good comments already - I'll make a second pass when those are addressed

src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved
@miniksa
Copy link
Member

miniksa commented Jul 10, 2019

Creating a public Azure DevOps Artifacts Feed may be a better option than checking in the NuGet packages.

@ras0219-msft, as far as I could find... this is not a thing that exists. There was no such thing as a public feed. There's a 100% private feed, and a partially private feed for just your org. But there's no straight up public feed that anyone can pull from.

@miniksa
Copy link
Member

miniksa commented Jul 10, 2019

Creating a public Azure DevOps Artifacts Feed may be a better option than checking in the NuGet packages.

@ras0219-msft Robert Schumacher FTE, as far as I could find... this is not a thing that exists. There was no such thing as a public feed. There's a 100% private feed, and a partially private feed for just your org. But there's no straight up public feed that anyone can pull from.

https://dev.azure.com/ms/Terminal has a banner on the top saying we can't publish artifacts after 7/15 without billing. @DHowett-MSFT, can you track down whomever owns the MS instance and have them fix the billing?

src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved

//Initialize the request
http_request tenantRequest(L"GET");
tenantRequest.set_request_uri(L"tenants?api-version=2018-01-01");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's intentional that they're different? It just looks like an accident/typo.

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jul 17, 2019
…r to App to create connection, arm64 *should* build now
src/cascadia/TerminalApp/App.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/App.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.h Outdated Show resolved Hide resolved
src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say none of my concerns really rise above the level of a nit. Nice work with this!

src/cascadia/TerminalConnection/AzureConnection.h Outdated Show resolved Hide resolved
src/cascadia/TerminalConnection/AzureConnection.h Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
// Remove the TabView from the page. We'll hang on to it, we need to
// put it in the titlebar.
uint32_t index = 0;
if (terminalPage->Root().Children().IndexOf(_tabRow,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we maybe (file a follow up task) to display an error dialog if they try using the azure connection type in arm64?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not be a bad idea, though I think its an issue that very few people will run into - there's no default profile for an azure connection in an arm64 build, so someone would have to build in non-arm64 first (therefore getting a profiles file with the azure connection as an option), and then build arm64 and use that same profiles file and then try to open up an azure connection to run into that error. At the same time its not hard to implement so I guess we could just do it

// - the handler
// Return value:
// - the event token for the handler
winrt::event_token AzureConnection::TerminalOutput(Microsoft::Terminal::TerminalConnection::TerminalOutputEventArgs const& handler)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might have some DEFINE_EVENT_HANDLER macros lying around so you don't need to put these in here manually, but they're fine for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. They're in src\cascadia\inc\cppwinrt_utils.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I was just following the way ConhostConnection.cpp did it

src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved
// We are connected, continuously read from the websocket until its closed
case State::termConnected:
{
while (true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't this state get it's own helper method too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It felt like the real meat of the output thread (since its the state we'll be in most of the time) so it really was just a stylistic choice to leave it there. Can change it if anyone feels strongly about it

src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure we have the Copyright header at the top of these new files. I think there's some missing.

Also, GitHub gave me a super not-useful diff on App.cpp and WindowsTerminal.vcxproj. I'll try and get around to those sometime, but I think there aren't many changes there right?

src/cascadia/TerminalApp/CascadiaSettings.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalConnection/AzureClientID.h Outdated Show resolved Hide resolved
// - the handler
// Return value:
// - the event token for the handler
winrt::event_token AzureConnection::TerminalOutput(Microsoft::Terminal::TerminalConnection::TerminalOutputEventArgs const& handler)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. They're in src\cascadia\inc\cppwinrt_utils.h

src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved
@miniksa
Copy link
Member

miniksa commented Jul 24, 2019

I still don't see notes anywhere about why ARM64 is compiled out.

I know why, we talked about it. I just want to see it commented in the code.

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple quick questions, but I wouldn't block on them.

_HeaderHelper(shellRequest);
const auto innerBody = json::value::parse(U("{ \"osType\" : \"linux\" }"));
json::value body;
body[U("properties")] = innerBody;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why you parsed json to get the inner value, then manually created the outer value. you could manually create both, or parse json ({"properties":{"osType":"linux"}}) for both 😄

src/cascadia/TerminalConnection/AzureConnection.cpp Outdated Show resolved Hide resolved
refreshRequest.set_request_uri(_tenantID + L"/oauth2/token");
const auto body = L"client_id=" + AzureClientID + L"&resource=" + _wantedResource + L"&grant_type=refresh_token" + L"&refresh_token=" + _refreshToken;
refreshRequest.set_body(body, L"application/x-www-form-urlencoded");
refreshRequest.headers().add(L"User-Agent", resource);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need a better user agent than Terminal; perhaps we can get it from the package version (like App.cpp does?)

@mcpiroman mcpiroman mentioned this pull request Jul 25, 2019
5 tasks
@miniksa
Copy link
Member

miniksa commented Jul 25, 2019

#2096 will remove the static analysis build here.

@miniksa
Copy link
Member

miniksa commented Jul 25, 2019

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PankajBhojwani PankajBhojwani merged commit 63347f4 into microsoft:master Jul 25, 2019
@PankajBhojwani PankajBhojwani deleted the realAzCon branch July 25, 2019 20:33
mcpiroman pushed a commit to mcpiroman/terminal that referenced this pull request Jul 26, 2019
* We can now connect to the Azure cloud shell microsoft#1235
@ghost
Copy link

ghost commented Aug 3, 2019

🎉Windows Terminal Preview v0.3.2142.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Azure cloud shell connector
7 participants