Skip to content

switch to the Az module for Azure #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/PSCoreApp/GetAzureVmHttpTrigger/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions src/PowerShell/PowerShellManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand All @@ -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)
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/requirements.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}