Connecting VScode to Azure Cloudshell - azure

I'm looking to connect VS Code to Azure Cloudshell, especially for the file explorer component.
It is a bit of an anti-pattern, but cloudshell is the only way in which I am able to run some commands that connect to Azure resources (spinning up a VM is not allowed).
I know the 'remote-ssh' extension can connect to a remote machine and provide a nice file explorer, however, for cloudshell I do not have ssh available. However, there is a connection possible through the 'Azure account' extension.
(There is also a 'remote tunnel' extension that is able to establish connections over different protocol than ssh).
This is the connection that 'Azure account' sets up with the cloudshell:
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
tcp ESTAB 0 0 10.xxx.xx.169:http-alt 10.xxx.xx.29:57404
tcp ESTAB 0 0 10.xxx.xx.169:51710 20.xxx.xx.200:microsoft-ds
Does anybody know if this can be used to get a full remote development experience in VScode connected to Azure cloudshell?
(I tried to install the vs code server rpm package in cloudshell, failed due to lacking yum and sudo permissions.)
Answer:
TLDR: type code . in azure Cloudshell in browser to get file editor.
(Using own IDE is not possible, only cloudshell as terminal)

Check the below steps to connect to Azure Cloud shell (PowerShell/Bash).
Open VSCode, = >Extensions => search for Azure Account.
Check whether Azure Account is Installed and Enabled.
If it is not done, Install and Enable it.
We need to Login to Azure Account to Open the Cloud shell.
In View tab => Command Palette => Azure: Sign in
OR
Press Ctrl + Shift + P => Azure: Sign in.
Click on Sign in and login to Azure.
You
In the right, click on the dropdown symbol beside + .You will find an option for Azure Cloud shell (PowerShell / Bash).
Select Azure Cloud shell (PowerShell) .
If it is not sign into Azure, you will get an option to Sign in.
Once after Sign, you will get the below message in the terminal.
To make sure we are connected to Azure Cloud shell, execute any of the PowerShell command and check once.
file explorer component
Thanks #Brendan Burn for the Post.
Refer this SO Thread regarding File Explorer.

Related

Unable to mount file on windows from Azure

I made a file on Azure using "File Service" and then tried to mount it using "connect". It has given me the username: localhost\xyz.
Two questions:
why username starting from "localhost" and not with "Azure"?
why I am unable to mount as windows security not giving any error, instead keep on turning back to credentials page?
p.s. TCP port 445 working properly..
Here are a few workarounds that worked for us.
WAY-1
You can directly go to your PowerShell of your machine and paste the script that you have provided in your storage account
WAY-2
You can click on More options and select for different account and then use the storage account name prepended with AZURE\ as the username and a storage account key as the password.
WAY-3
You can create a file share directly by unchecking the connect using different credentials.
OUTPUT:
For all the above ways here is the screenshot of fileshares that got mounted.
REFERENCES:
Mount SMB Azure file share on Windows

When start Azure cosmos db emulator It is show Unable to add firewall rule settings. Please restart the Azure Cosmos Emulator with/NoFirewall Option

I installed Azure cosmos db Emulator in my office laptop. First it is shows 8081 already running. I changed the port issue resolved.
But it showing Unable to add firewall rule settings. Please restart the Azure Cosmos Emulator with/NOFirewall Option.
I try with below 2 commands in CMD
Microsoft.Azure.Cosmos.Emulator.exe /NoFirewall Microsoft.Azure.Cosmos.Emulator.exe /port=1729/NOFirewall Microsoft.Azure.Cosmos.Emulator.exe [/NOFirewall] [/port=1729]
But I the issue not resolved. Please help me to solve this issue.
[1]: https://i.stack.imgur.com/sgw2G.png
Generate a new authorization key and save to the specified file. The generated key can be used with the /Key or /KeyFile options.
Microsoft.Azure.Cosmos.Emulator.exe /GenKeyFile=<path to key file
If the emulator is already running, shut it off.
Next, remove the emulator's data directory from the following path:
(C:\Users\user name\AppData\Local\CosmosDBEmulator)
Run the following command to restart the emulator:
/AllowNetworkAccess /KeyFile=generatedKey /NoFirewall /Port=#####
Please refer for the command-line parameters or to Troubleshoot issues when using the Azure Cosmos DB Emulator
Note: You can use any port you like, but make sure it isn't currently in use. For the data explorer to continue operating, you must replace your created key with the default key.
I had the same issue. Kindly check if your system has admin rights. If not you will be needing to get it by adding your id local admin list.
Open CMD
Type lusrmgr. It will redirect you to Local Users and Groups.
Enter Groups.
Open Administrator.
Select Add.
Under Enter the object names to select provide your primary email Id.
Restart.
And voila you are now the admin of your system.

Getting error in Cloudshell: Connect-AzAccount: InteractiveBrowserCredential authentication failed

I have an existing paid Azure subscription. SOmehow, I failed to pay my bills and subscription got deactivated and then I paid and activated again
But after this incident, I am getting one strange error in Cloudshell as follows:
a) From my Win 10 machine, I opened Chrome/ Edge browser
b) Logged in to Azure Portal
c) Opened Cloud shell and Opened PWSH mode
d) Types in Connect-AZAccount
Getting following warning and then an error:
--> WARNING: Unable to acquire token for tenant 'organizations'
--> Connect-AzAccount: InteractiveBrowserCredential authentication failed: Unable to open a web page using xdg-open. See inner exception for details. Possible causes for this error are: xdg-open is not installed or it cannot find a way to open an url - make sure you can open a web page by invoking from a terminal: xdg-open https://www.bing.com
This never happened earlier and I always used before normally. Also I tried with some other Window systems. Same error. But when I tried to use installed Powershell it works as charm. Please advise what went wrong
If you use Cloud Shell, then you don't need to use this command to connect to Azure.Your Azure Cloud Shell session is already authenticated for the environment, subscription, and tenant that launched the Cloud Shell session.
Please see the documentation:
Sign in interactively with the Connect-AzAccount cmdlet. Skip this
step if you use Cloud Shell. Your Azure Cloud Shell session is already
authenticated for the environment, subscription, and tenant that
launched the Cloud Shell session.

Unable to add ssh key in azure vm

I am the admin of this particular azure subscription. I had to add my ssh key to a ubuntu server. But when I try to add the ssh key through "Reset Password", After sometime I'll get the following error message.
VM agent on VM 'Server' has not reported latest status for extension 'enablevmaccess'. Please verify the VM has a running VM agent and can establish outbound connections to Azure storage.
What might be the issue? How to resolve this?
Failed to reset ssh key
vmaccess is enabled
Two simple thing you might try;
Uninstall the VMAccess extension and try reset again.
Use the 'Run Command' to set/reset password.
Hope this helps.
your first error tells you exactly why this happens. vm extension needs to talk to azure storage to report extension status. if it cant - portal operations might fail (this doesnt mean the extension failed; its just unable to report actual extension status).

How to copy files & run commands on remote Azure Win VM?

From my local Windows command prompt, I can copy files to local Windows machines, and run commands on the local Windows machines with psexec. (For example, launching .bat files). I can also start/stop and query services on the Windows machines, for example with sc \machineIP query (servicename).
I am learning to be able to do the same thing with a stock Windows machine hosted in Azure.
Having created a stock Windows Server VM in Azure from the command line, what more must I do? Currently on the Azure VM, for testing, I have:
Turned off the Firewall
Disabled simple file sharing wizard
Shared C, with permissions for 'everyone'
Started 'remote registry' service
Added registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy with value of 1 (hex)
I am able to RDP to the machine without a problem, with the given public IP address, username, and password.
I note that I cannot access: \publicIP\c$
And psexec returns 'The network path was not found. Make sure the default admin$ share is enabled on (publicIP)' when running the command:
psexec.exe \\(publicIP) -u(username) -p (password) -i 1 cmd /c c:\runMe.bat
In the Azure portal, navigate into the resource group where your VM resides. Select the 'Network Security Group' profile used by your VM (eg, yourVMnameNSG) -> edit -> add inbound security rules.
eg:
Name: psexec
Source: any
Destination: any
Service: Custom (Any/135)
Action: allow
Repeat for required services

Resources