locked
PowerShell 6.0RC on OSX and using AzureRm PS modules RRS feed

  • Question

  • Hello,

    I'm running into an issue trying to use PowerShell 6 RC on OSX with the AzureRM.Netcore and AzureRM.Sql modules.

    My goal, the overarching thing for here is that I want to do the following:
    1.  Initiate a database export from one of our SQL Server databases -> Storage Account
    2.  Wait for that process to complete.
    3.  Download that file from the storage account.

    To my knowledge, AzureRM.Sql is the only module that has the command New-AzureRmSqlDatabaseExport.  The examples of output I ran is in a gist, I'll use a link to the specific line number after each part.  I should also add that I'm a PowerShell novice.  A lot I need to learn yet, most of this was after reading many guides and Q&As

    The steps I ran to setup was:
    1.  Install Powershell from homebrew
    2.  Install the modules under local scope (Install-Module ..)
    3.  Attempt to log in with "Login-AzureRmAccount"

    There are a few issues that are going on:
    1.  If I try to install both modules (AzureRM.Netcore, AzureRM.Sql), I'm unable to use the command Login-AzureRmAccount.  I use "Import-Module -Name AzureRM.Netcore", and the command can't be found.  A combination of "-Force" and "-DisableNameChecking" doesn't help the situation.  Hitting tab, after the Login-AzureRmAccount, will result in duplicate "Login-AzureRmAccount" statements to show as available.  Get-Command returns one copy, which is the alias.


    2.  When I try to load the AzureRm.Sql, alone, I get the following error:
    "Import-Module : Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
    At /Users/dthole/.local/share/powershell/Modules/AzureRM.profile/4.1.1/AzureRM.Profile.psm1:12 char:1
    + Import-Module (Join-Path -Path $PSScriptRoot -ChildPath Microsoft.Azu ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand"

    If I load AzureRm.Netcore first, then I can load AzureRM.Sql (requires two tries, actually).  After loading both, still using "Login-AzureRmAccount" still doesn't work.

    If I run "Get-Command" on this first, I get:
    TheDarkTrumpet/f54e4f597e87a918a6820164d0312c12#file-pwsh-ps1-L2

    But two show up during tab completion (Login-AzureRmAccount [TAB] will show 2 entries).  Loading the module AzureRM.profile then trying again doesn't help. Currently trying to find out if there's a way to run a specific one of the two.

    3.  If I start fresh, and remove all modules, and just install AzureRM.Netcore, that does work:
    gist.github.com/TheDarkTrumpet/f54e4f597e87a918a6820164d0312c12#file-pwsh-ps1-L9


    4.  If I start fresh, and remove all modules, and just install AzureRM.Sql, that doesn't work:
    gist.github.com/TheDarkTrumpet/f54e4f597e87a918a6820164d0312c12#file-pwsh-ps1-L26


    I'm available if anyone wants to see this done in "live" mode.  I'm on Skype for Business, and can be contacted through my work email.  If this is a desire, please let me know and I'll post that information.

    Wednesday, December 13, 2017 9:03 PM

Answers

  • Hi Micah,

    Thanks for the suggestion.  It's one I considered, but am thinking of just using my virtual machine with PowerShell on there.  As long as I stay out of the Core-like modules, it may be better anyways.  I originally did try what you suggested, but I don't think I have permissions in Azure to do all of it, and didn't want to bother our systems people to get it setup.  Especially if i have a solution that could work for now.

    Looking at both PS6 and the AzureRM backlog, it's...extensive to say the least. Over a thousand bug reports in both, it may be a good 6m to a year before we see this become stable.  A shame really, but I'll check it out periodically to see if stuff like what I mentioned are resolved and if so try to migrate over again.

    Thursday, December 14, 2017 2:51 PM

All replies

  • Hi David, 

    Personally I do not know too much in regards to running PowerShell on things other than Windows Devices. From your explanation it does not sound like you are doing anything wrong rather running PowerShell on OSX might just be a tad more difficult than on Windows. 

    Therefore, I will let people with more expertise on PowerShell on OSX help with that issue however I believe I have a workaround that you could use in the meantime if that helps at all. 

    We now offer the ability to run PowerShell and Azure CLI from the portal itself. This eliminates the need to run any of the login-Azure commands. It also has all of the modules built in already so you shouldn't need to load any additional SQL modules. 

    To initiate a PowerShell session from the Portal simply login and at the top right corner select the following icon: 

    You will be prompted to create a cloud-storage-account. Select yes and let that create. It can take a few mins FYI. Once it has created a CLI session will begin to start. Select the dropdown that says BASH and change it to PowerShell. Allow the cloud shell to restart and PowerShell should start up. 

    Hope this can at least get you started on your project! 

    -Micah

    Wednesday, December 13, 2017 10:19 PM
  • Hi Micah,

    Thanks for the suggestion.  It's one I considered, but am thinking of just using my virtual machine with PowerShell on there.  As long as I stay out of the Core-like modules, it may be better anyways.  I originally did try what you suggested, but I don't think I have permissions in Azure to do all of it, and didn't want to bother our systems people to get it setup.  Especially if i have a solution that could work for now.

    Looking at both PS6 and the AzureRM backlog, it's...extensive to say the least. Over a thousand bug reports in both, it may be a good 6m to a year before we see this become stable.  A shame really, but I'll check it out periodically to see if stuff like what I mentioned are resolved and if so try to migrate over again.

    Thursday, December 14, 2017 2:51 PM
  • Hi David, 

    Yes another great option I have had many people who work off of OSX is to use is a windows VM as you mentioned. That way you do get the full functionality you are looking for. I too saw the extensive backlog which in all honestly is a reason I would personally steer away from it until they are able to deliver a more polished product. At least they are working on it I suppose :) 

    If you hit any further snags feel free to reach back out! 

    -Micah

    Thursday, December 14, 2017 5:25 PM