Comments (33)
@chrmarti thanks for replying. We need a way to run commands and show user the output.
from vscode-azure-account.
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.
from vscode-azure-account.
I guess I cannot use Azure SDK to do that. I would like to send some terraform command to the cloud shell.
from vscode-azure-account.
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!
from vscode-azure-account.
@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.
from vscode-azure-account.
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:
- upload files to cloudshell
- get cloud shell terminal instance or at least cloud shell connection status.
from vscode-azure-account.
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?
from vscode-azure-account.
There is not today, but this is something we have been reviewing. Adding @yangl900 as FYI.
from vscode-azure-account.
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
from vscode-azure-account.
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:
- the resource group of the storage account
- the storage account name
- the fileshare name
- the storage account key
from vscode-azure-account.
I would not feel comfortable exposing these details from the Cloud Shell's configuration. I have instead added a session
property to this experimental API that you can use to look up the configuration yourself. You could copy the following code to do so:
- Extract a token from the session: https://github.com/Microsoft/vscode-azure-account/blob/b78b7ecba7c395990ad17f906de907835442338e/src/cloudConsole.ts#L321
- Fetch the configuration: https://github.com/Microsoft/vscode-azure-account/blob/b78b7ecba7c395990ad17f906de907835442338e/src/cloudConsoleLauncher.ts#L28
Hope that works for you. I have also reduced the number of status
values and made the terminal
and session
properties promises.
from vscode-azure-account.
@chrmarti I agree with what you said. I'll try for this ASAP and tells you if it works on my side. Thanks.
from vscode-azure-account.
@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.
from vscode-azure-account.
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 connecting
. Is this by design?
from vscode-azure-account.
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 .show()
on it, which you can do immediately or later, as works best for you.)
from vscode-azure-account.
I could add a waitForConnection
function returning a Promise<boolean>
that resolves to true
when the connection is available and false
when the connection failed. That would align with other parts of the API and make it easier to start sending text.
from vscode-azure-account.
Thanks, waitForConnection()
looks good to me.
And FYI, just as you said, the the storage account can be accessed as soon as the session promise resolves.
from vscode-azure-account.
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();
}
from vscode-azure-account.
Thanks for the information.
from vscode-azure-account.
Hi @chrmarti . May I ask when will you remove the experimental
property for this API. I'm thinking that if I published the extension using this API, the extension may break when the Azure-Account is updated to remvoe the experimental
property. Do you have any suggestions on this?
from vscode-azure-account.
@jdneo I can move it up when you confirm that it works for your use cases.
@yungez Did you have a chance to give it a try?
from vscode-azure-account.
Yes it works fine for my use cases now. Thanks!
from vscode-azure-account.
Took the opportunity of a bug fix release to move this out of experimental
.
from vscode-azure-account.
@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
from vscode-azure-account.
@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 1.21.0
, everything works fine. I'll check the new API later.
from vscode-azure-account.
@jdneo The extension uses new API from 1.22. It should run fine with the 1.22 insiders release of VS Code.
from vscode-azure-account.
Thanks for the information. I was just directly calling the Azure: Upload to Cloud Shell
to understand the behavior, but seems nothing happened. 😢
from vscode-azure-account.
Is there anything in the console? (Help > Toggle Developer Tools)
from vscode-azure-account.
yes, Bad progress location: undefined
from vscode-azure-account.
Maybe you need to rebuild the vsix
with the engine set to 1.22
first? I just tried and it works for me.
from vscode-azure-account.
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 $HOME
folder. Is it possible that if we can specify the path for each file. For example clouddrive/myprojet/file.txt
. Here clouddrive
is the Azure File Share mounted by Cloud Shell.
from vscode-azure-account.
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?
from vscode-azure-account.
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.
from vscode-azure-account.
Related Issues (20)
- Cannot list subscriptions. HOT 2
- request to https://management.azure.com/subscriptions?api-version=2016-06-01 failed, reason: getaddrinfo ENOTFOUND management.azure.com HOT 4
- Timed out waiting for authentication provider to register HOT 12
- UNABLE TO LOUGOUT USING AZURE: SIGN OUT
- Azure key
- Cannot use Azure Sign Out HOT 14
- Cannot list subscriptions: Not able to see the subscription listed in Visual studio code
- dh-az-orko HOT 1
- Bug report
- Cannot list subscriptions
- Documentation on Proxy is not a solution HOT 1
- VSCode doesn't work with 2FA
- Cannot change tenant HOT 2
- I get zero subscriptions to select from when creating a new azure function in visual studio code.
- I am unable to select the subscription HOT 1
- having issue
- Logged into Azure but cannot access subscription or resources HOT 2
- Cannot list subscriptions
- Cannot sign in while using proxy HOT 2
- sdkopen HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-azure-account.