-
Notifications
You must be signed in to change notification settings - Fork 129
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
Add API to create a Cloud Shell terminal #34
Comments
There is currently no way to do this. What kind of commands do you want to send? Could you use the Azure SDK to achieve the same? The Account extension has API with the credentials object for the Azure SDK. |
I guess I cannot use Azure SDK to do that. I would like to send some terraform command to the cloud shell. |
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines. Happy Coding! |
@chrmarti thanks for reopen it. If this can be supported, there is no need for me to copy-paste your cloud shell code to my extension. As far as I know, there are several extensions that are using azure cloud shell. It will be great if we can get the terminal instance from azure-account-extension. |
we have same request on cloud shell sdk supporting. We're building vscode ansible extension, ansible is also runnable from cloudshell. we'd like to see features like:
|
Are you looking for a way to only run commands or do you also need the terminal UI to show the user the output and maybe collect input? I'm not aware of a way to upload files to the Cloud Shell. @jluk Is there a REST API for that? |
There is not today, but this is something we have been reviewing. Adding @yangl900 as FYI. |
@chrmarti thanks for replying. We need a way to run commands and show user the output. |
I have pushed (not published yet) a draft of such an API. Let me know if that looks like it would cover your use case: https://github.com/Microsoft/vscode-azure-account/blob/1686b7cb6f544732723da70bd87fc164d44ccb93/src/azure-account.api.d.ts#L29 |
Hi @chrmarti I've tested the new API on my machine. And that works! Really appreciated! About the upload files to Cloud Shell. If it is impossible for now. Could we add more fields about the cloud shell's storage account information in the returned CloudShell object. Then we can do the uploading by ourselves. What we need are:
|
I would not feel comfortable exposing these details from the Cloud Shell's configuration. I have instead added a
Hope that works for you. I have also reduced the number of |
@chrmarti I agree with what you said. I'll try for this ASAP and tells you if it works on my side. Thanks. |
@jdneo Just published a bugfix release of the extension that includes this experimental API. We can promote it to 'stable' (moving it up from the 'experimental' property) after this round of feedback. |
Hi @chrmarti I changed my code according to your suggestion as following: ...
const accountAPI: AzureAccount = vscode.extensions
.getExtension<AzureAccount>("ms-vscode.azure-account")!.exports;
const cloudShell: CloudShell = accountAPI.experimental.createCloudShell("Linux");
this.tfTerminal.terminal = await cloudShell.terminal;
const storageAccount: IStorageAccount = await getStorageAccountforCloudShell(cloudShell);
... And this is the screenshot when I debug my code: As you can see, though we await for the terminal, but after the promise is resolved, the status of cloudshell is still |
Yes, the terminal is available while the connection is still being set up (we show progress messages in the terminal during connection setup). You should be able to access the storage account as soon as the session promise resolves (which is also while the status is still 'Connecting'). Before sending text to the terminal, you would probably wait for the status to change to 'Connected'. (Also note that the terminal will not show until you call |
I could add a |
Thanks, And FYI, just as you said, the the storage account can be accessed as soon as the session promise resolves. |
You could use this code until the next release: async function waitForConnection(cloudShell: CloudShell) {
const handleStatus = () => {
switch(cloudShell.status) {
case 'Connecting':
return new Promise<boolean>(resolve => {
const subs = cloudShell.onStatusChanged(() => {
subs.dispose();
resolve(handleStatus());
});
});
case 'Connected':
return true;
case 'Disconnected':
return false;
default:
const status: never = cloudShell.status;
throw new Error(`Unexpected status '${status}'`);
}
};
return handleStatus();
} |
Thanks for the information. |
Hi @chrmarti . May I ask when will you remove the |
Yes it works fine for my use cases now. Thanks! |
Took the opportunity of a bug fix release to move this out of |
@jdneo I have pushed an addition to the API for uploading files to the master branch. Could you check if that will work for you: https://github.com/Microsoft/vscode-azure-account/blob/f0846fc601554ddb3f945e34e6a85551b705fca7/src/azure-account.api.d.ts#L57 |
@chrmarti Awesome! I'm trying to local generate the vsix file and install the extension locally, but it always need me to reload the VS Code, seems the extension cannot be started up. Do you have any idea on that? Oh, that is because the engines defined in package.json is an unreleased version of vscode. After change it to |
@jdneo The extension uses new API from 1.22. It should run fine with the 1.22 insiders release of VS Code. |
Thanks for the information. I was just directly calling the |
Is there anything in the console? (Help > Toggle Developer Tools) |
yes, |
Maybe you need to rebuild the |
I see. Just as you have said. After rebuilding the vsix and install it in VS Code Insider, everything works fine. I just have one question: Seems currently we will always upload files to the |
That seems to be a limitation of the Upload API. @jluk Is there a way to upload files to a different folder than the home folder? |
Not right now, bash supports pushing to $home and PS supports pushing to $clouddrive. We'll be improving this down the road, but this is the case for now. |
Currently the Azure Account Extension support launch to the cloud shell in the vscode.
If I have a extension depend on Azure Account Extension, is there any way that can get the terminal instance that created by Azure Account Extension, then I can send command to this terminal?
The text was updated successfully, but these errors were encountered: