Microsoft Azure Cloud Shell has a nice feature that allows the cloud administrator to use the Cloud Shell editor in just a few steps.
But before getting to the feature, I like to save the files that I’m generating with the subscription name prefix, and for that, we could use the following PowerShell cmdlet to get the subscription name.
$SubName = (Get-AzureRmContext).Subscription.Name
The second step to understand is that using Cloud Shell we have a location to save our files/scripts. (I explored that in this article here at TechGenix), and that information is accessible through the shell using the command below. Even at the Storage Account level, we should have a File Share for our users on that area.
Get-AzureRmResource | where { ($_.ResourceType -eq ‘Microsoft.Network/networkInterfaces’) -or ($_.ResourceType -eq ‘Microsoft.Network/networkSecurityGroups’)} | select Name,ResourceID,ResourceType,Location | export-csv -path ($home + "/clouddrive/" + $SubName + "-NSG_and_NI.csv") –NoTypeInformation
The two lines of code above can be seen in action in the image below. Basically, we retrieved the subscription name, and generated a list of all network security groups and network interfaces in that given subscription in a CSV file called <subscriptionName>-NSG_and_NI.csv
Time to use the Cloud Shell editor feature. Click on {} and the Cloud Shell explorer will be displayed. Expand clouddrive, which persists on all your Cloud Shell sessions, and we will see the file that we have just generated listed there. Click on it, and the content will be displayed on the right side.
We can perform editions, copy and paste, open new files, and so forth. There is a … button on the upper right corner of the Cloud Shell editor that has all those options available.
You can always go back and use all-time favorites such as vi, nano, and emacs. However, for fast and perhaps more sophisticated options, we can count on File Editor.
Featured image: Shutterstock