diff --git a/build.ps1 b/build.ps1 index ffcff289..20f103b9 100644 --- a/build.ps1 +++ b/build.ps1 @@ -78,6 +78,7 @@ if($Test.IsPresent) { } dotnet test "$PSScriptRoot/test" + if ($LASTEXITCODE -ne 0) { throw "xunit tests failed." } if($env:APPVEYOR) { $res = Invoke-Pester "$PSScriptRoot/test/Modules" -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru diff --git a/examples/PSCoreApp/GetAzureVmHttpTrigger/run.ps1 b/examples/PSCoreApp/GetAzureVmHttpTrigger/run.ps1 index 7b285583..c635e521 100644 --- a/examples/PSCoreApp/GetAzureVmHttpTrigger/run.ps1 +++ b/examples/PSCoreApp/GetAzureVmHttpTrigger/run.ps1 @@ -13,7 +13,7 @@ $cmdletParameters.ErrorAction = "Stop" try { # Splat the parameters that were passed in via query parameters - $vms = Get-AzureRmVM @cmdletParameters + $vms = Get-AzVM @cmdletParameters $response = [HttpResponseContext]@{ StatusCode = '200' # OK Body = ($vms | ConvertTo-Json) diff --git a/src/PowerShell/PowerShellManager.cs b/src/PowerShell/PowerShellManager.cs index 35ca5b52..7fc21ca8 100644 --- a/src/PowerShell/PowerShellManager.cs +++ b/src/PowerShell/PowerShellManager.cs @@ -54,9 +54,9 @@ internal void AuthenticateToAzure() { // Try to authenticate to Azure // TODO: The Azure Functions Host might supply these differently. This might change but works for the demo - string applicationId = Environment.GetEnvironmentVariable("ApplicationId"); - string applicationSecret = Environment.GetEnvironmentVariable("ApplicationSecret"); - string tenantId = Environment.GetEnvironmentVariable("TenantId"); + string applicationId = Environment.GetEnvironmentVariable("APPSETTING_WEBSITE_AUTH_CLIENT_ID"); + string applicationSecret = Environment.GetEnvironmentVariable("APPSETTING_WEBSITE_AUTH_CLIENT_SECRET"); + string tenantId = Environment.GetEnvironmentVariable("APPSETTING_WEBSITE_AUTH_TENANT_ID"); if (string.IsNullOrEmpty(applicationId) || string.IsNullOrEmpty(applicationSecret) || @@ -75,7 +75,7 @@ internal void AuthenticateToAzure() using (ExecutionTimer.Start(_logger, "Authentication to Azure completed.")) { - _pwsh.AddCommand("Connect-AzureRmAccount") + _pwsh.AddCommand("Az.Profile\\Connect-AzAccount") .AddParameter("Credential", new PSCredential(applicationId, secureString)) .AddParameter("ServicePrincipal") .AddParameter("TenantId", tenantId) @@ -91,9 +91,6 @@ internal void InitializeRunspace() // Set the PSModulePath Environment.SetEnvironmentVariable("PSModulePath", Path.Join(AppDomain.CurrentDomain.BaseDirectory, "Modules")); - - // TODO: remove this when we figure out why it fixed #48 - _pwsh.AddCommand("Microsoft.PowerShell.Core\\Import-Module").AddParameter("Name", "AzureRm.Netcore").InvokeAndClearCommands(); AuthenticateToAzure(); } diff --git a/src/requirements.psd1 b/src/requirements.psd1 index 2affa5c2..e6adf705 100644 --- a/src/requirements.psd1 +++ b/src/requirements.psd1 @@ -8,8 +8,8 @@ Version = '1.1.0.0' Target = 'src/Modules' } - 'AzureRM.Netcore' = @{ - Version = '0.13.1' + 'Az' = @{ + Version = '0.2.2' Target = 'src/Modules' } }