Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
markcowl authored Jan 18, 2019
2 parents d7a49f9 + 2f04d36 commit a3e3a4f
Show file tree
Hide file tree
Showing 99 changed files with 345 additions and 284 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ After the solution file is updated, save and close it. Now, open the solution fi
<PsModuleName>Cdn</PsModuleName>
</PropertyGroup>
```
- Remove the entry:
- **Remove the entry**:
```xml
<PropertyGroup>
<RootNamespace>$(LegacyAssemblyPrefix)$(PsModuleName)</RootNamespace>
</PropertyGroup>
```
This is not needed since this is a new project.
**This is not needed since this is a new project and does not use legacy namespace conventions.**

- Update this entry to use your SDK:
```xml
Expand Down
1 change: 1 addition & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->
## Upcoming Release
* Update incorrect online help URLs
* Add warning message in PS Core for Uninstall-AzureRm

## Version 1.1.0
* Add 'Local' Scope to Enable-AzureRmAlias
Expand Down
11 changes: 11 additions & 0 deletions src/Accounts/Accounts/UninstallAzureRm/UninstallAzureRm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.ResourceManager.Common;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand All @@ -33,6 +34,16 @@ public class UninstallAzureRmCommand : AzureRMCmdlet

public override void ExecuteCmdlet()
{
if (this.SessionState != null)
{
var version = (this.SessionState.PSVariable.Get("PSVersionTable").Value as Hashtable)["PSVersion"];
if (Convert.ToInt64(version.ToString().Substring(0, 1)) >= 6)
{
WriteWarning("Running this cmdlet in PowerShell Core will not remove the modules from PowerShell 5.1. " +
"Please rerun this cmdlet in a PowerShell 5.1 session to remove the modules from PowerShell 5.1.");
}
}

List<string> AzureModules = new List<string> { "Azure.AnalysisServices", "Azure.Storage", "AzureRM", "AzureRM.AnalysisServices",
"AzureRM.ApiManagement", "AzureRM.ApplicationInsights", "AzureRM.Automation", "AzureRM.Backup", "AzureRM.Batch", "AzureRM.Billing",
"AzureRM.Cdn", "AzureRM.CognitiveServices", "AzureRM.Compute", "AzureRM.Compute.Experiments", "AzureRM.Consumption",
Expand Down
25 changes: 5 additions & 20 deletions src/Accounts/Accounts/help/Connect-AzAccount.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml
Module Name: Az.Accounts
online version: https://docs.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount
Expand Down Expand Up @@ -74,22 +74,7 @@ This command connects to an Azure account.
To run Azure Resource Manager cmdlets with this account, you must provide Microsoft account or organizational ID credentials at the prompt.
If multi-factor authentication is enabled for your credentials, you must log in using the interactive option or use service principal authentication.

### Example 2: Connect to an Azure account using organizational ID credentials
```powershell
PS C:\> $Credential = Get-Credential
PS C:\> Connect-AzAccount -Credential $Credential
Account SubscriptionName TenantId Environment
------- ---------------- -------- -----------
azureuser@contoso.com Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
```

The first command will prompt for user credentials (username and password), and then stores them in the $Credential variable.
The second command connects to an Azure account using the credentials stored in $Credential.
This account authenticates with Azure Resource Manager using organizational ID credentials.
You cannot use multi-factor authentication or Microsoft account credentials to run Azure Resource Manager cmdlets with this account.

### Example 3: Connect to an Azure service principal account
### Example 2: Connect to an Azure service principal account
```powershell
PS C:\> $Credential = Get-Credential
Expand All @@ -103,7 +88,7 @@ The first command gets the service principal credentials (application id and ser
The second command connect to Azure using the service principal credentials stored in $Credential for the specified Tenant.
The ServicePrincipal switch parameter indicates that the account authenticates as a service principal.

### Example 4: Use an interactive login to connect to an account for a specific tenant and subscription
### Example 3: Use an interactive login to connect to an account for a specific tenant and subscription
```powershell
PS C:\> Connect-AzAccount -Tenant "xxxx-xxxx-xxxx-xxxx" -SubscriptionId "yyyy-yyyy-yyyy-yyyy"
Account SubscriptionName TenantId Environment
Expand All @@ -113,7 +98,7 @@ azureuser@contoso.com Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud

This command connects to an Azure account and configured AzureRM PowerShell to run cmdlets for the specified tenant and subscription by default.

### Example 5: Add an Account Using Managed Service Identity Login
### Example 4: Add an Account Using Managed Service Identity Login
```powershell
PS C:\> Connect-AzAccount -MSI
Expand All @@ -125,7 +110,7 @@ MSI@50342 Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
This command connects using the managed service identity of the host environment (for example, if executed on a
VirtualMachine with an assigned Managed Service Identity, this will allow the code to login using that assigned identity)

### Example 6: Add an account using certificates
### Example 5: Add an account using certificates
```powershell
# For more information on creating a self-signed certificate
# and giving it proper permissions, please see the following:
Expand Down
2 changes: 1 addition & 1 deletion src/Accounts/Accounts/help/Uninstall-AzureRm.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Removes all AzureRm modules from a machine.
PS C:\> Uninstall-AzureRm
```

Running this command will remove all AzureRm modules from the machine.
Running this command will remove all AzureRm modules from the machine for the version of PowerShell in which the cmdlet is run.

## PARAMETERS

Expand Down
10 changes: 9 additions & 1 deletion src/Automation/Automation.Test/ScenarioTests/AutomationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,15 @@ public void TestAutomationStartUnpublishedRunbook()
[Trait(Category.Service, Category.Automation)]
public void TestAutomationRunbookWithParameter()
{
RunPowerShellTest(_logger, "Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.ps1 @{'nums'='[1,2,3,4,5,6,7]'} 28");
RunPowerShellTest(_logger, "Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.ps1 -type 'PowerShell' -parameters @{'nums'='[1,2,3,4,5,6,7]'} -expectedResult 28");
}

[Fact(Skip = "Need x64 test framework.")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Service, Category.Automation)]
public void TestAutomationPy2RunbookWithParameter()
{
RunPowerShellTest(_logger, "Test-RunbookWithParameter -runbookPath ScenarioTests\\Resources\\fastJob.py -type 'Python2' -parameters @{'param1'='1';'param2'='2';'param3'='3';'param4'='4';'param5'='5';'param6'='6';'param7'='7'} -expectedResult 28");
}
}
}
14 changes: 7 additions & 7 deletions src/Automation/Automation.Test/ScenarioTests/AutomationTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ Checks whether the runbook exists and if it exists, removes it and then imports
#>
function CreateRunbook
{
param([string] $runbookPath, [boolean] $byName=$false, [string[]] $tag, [string] $description)
param([string] $runbookPath, [boolean] $byName=$false, [string[]] $tag, [string] $description, [string] $type = "PowerShell")

$runbookName = gci $runbookPath | %{$_.BaseName}
$runbook = Get-AzureRmAutomationRunbook $accountName | where {$_.Name -eq $runbookName}
$runbook = Get-AzureRmAutomationRunbook $accountName | where {$_.Name -eq $runbookName -and $_.RunbookType -eq $type}
if ($runbook.Count -eq 1)
{
Remove-AzureRmAutomationRunbook $accountName -Name $runbookName -Force
$runbook | Remove-AzureRmAutomationRunbook -Force
}

if(!$byName)
{
return New-AzureRmAutomationRunbook $accountName -Path $runbookPath -Tag $tag -Description $description
return New-AzureRmAutomationRunbook $accountName -Path $runbookPath -Tag $tag -Description $description -Type $type
}
else
{
return New-AzureRmAutomationRunbook $accountName -Name $runbookName -Tag $tag -Description $description
return New-AzureRmAutomationRunbook $accountName -Name $runbookName -Tag $tag -Description $description -Type $type
}
}

Expand Down Expand Up @@ -101,13 +101,13 @@ Tests Runbook with Parameters
#>
function Test-RunbookWithParameter
{
param([string] $runbookPath, [HashTable] $parameters, [int]$expectedResult)
param([string] $runbookPath, [string] $type, [HashTable] $parameters, [int]$expectedResult)

#Setup
$automationAccount = Get-AzureRmAutomationAccount -Name $accountName
Assert-NotNull $automationAccount "Automation account $accountName does not exist."

$runbook = CreateRunbook $runbookPath
$runbook = CreateRunbook $runbookPath -type $type
Assert-NotNull $runbook "runBook $runbookPath does not import successfully."
$automationAccount | Publish-AzureRmAutomationRunbook -Name $runbook.Name

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import sys

sum = 0
for i in range(1,len(sys.argv)):
sum = sum + int(sys.argv[i])

print(sum)
1 change: 1 addition & 0 deletions src/Automation/Automation/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Added support for Python 2 runbooks
* Update incorrect online help URLs

## Version 1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class NewAzureAutomationRunbook : AzureAutomationBaseCmdlet
Constants.RunbookType.PowerShellWorkflow,
Constants.RunbookType.GraphicalPowerShellWorkflow,
Constants.RunbookType.Graph,
Constants.RunbookType.Python2,
IgnoreCase = true)]
[ValidateNotNullOrEmpty]
public string Type { get; set; }
Expand Down
77 changes: 56 additions & 21 deletions src/Automation/Automation/Common/AutomationPSClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1657,42 +1657,77 @@ private IEnumerable<KeyValuePair<string, RunbookParameter>> ListRunbookParameter
private IDictionary<string, string> ProcessRunbookParameters(string resourceGroupName, string automationAccountName, string runbookName,
IDictionary parameters)
{
Runbook runbook = null;
IEnumerable<KeyValuePair<string, RunbookParameter>> runbookParameters = null;
parameters = parameters ?? new Dictionary<string, string>();
IEnumerable<KeyValuePair<string, RunbookParameter>> runbookParameters =
this.ListRunbookParameters(resourceGroupName, automationAccountName, runbookName);
var filteredParameters = new Dictionary<string, string>();

foreach (var runbookParameter in runbookParameters)
try
{
if (parameters.Contains(runbookParameter.Key))
runbook = this.GetRunbook(resourceGroupName, automationAccountName, runbookName);
}
catch (ResourceCommonException)
{
// Ignore if runbook does not exists in the account. This is to start global runbooks by name
runbookParameters = new Dictionary<string, RunbookParameter>();
}

if (runbook != null && 0 == String.Compare(runbook.State, RunbookState.New, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase))
{
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
Resources.RunbookHasNoPublishedVersion, runbookName));
}

if (runbook != null && runbook.RunbookType == "Python2") {
int i = 1;

foreach (var key in parameters.Keys) {
object paramValue = parameters[key];
try {
filteredParameters.Add("[Parameter " + i.ToString() + "]", PowerShellJsonConverter.Serialize(paramValue));
}
catch(JsonSerializationException)
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.RunbookParameterCannotBeSerializedToJson, key));
}
i++;
}
}
else {
runbookParameters = runbook.Parameters.Cast<DictionaryEntry>().ToDictionary(k => k.Key.ToString(), k => (RunbookParameter)k.Value);

foreach (var runbookParameter in runbookParameters)
{
object paramValue = parameters[runbookParameter.Key];
try
if (parameters.Contains(runbookParameter.Key))
{
filteredParameters.Add(runbookParameter.Key, PowerShellJsonConverter.Serialize(paramValue));
object paramValue = parameters[runbookParameter.Key];
try
{
filteredParameters.Add(runbookParameter.Key, PowerShellJsonConverter.Serialize(paramValue));
}
catch (JsonSerializationException)
{
throw new ArgumentException(
string.Format(
CultureInfo.CurrentCulture, Resources.RunbookParameterCannotBeSerializedToJson,
runbookParameter.Key));
}
}
catch (JsonSerializationException)
else if (runbookParameter.Value.IsMandatory.HasValue && runbookParameter.Value.IsMandatory.Value)
{
throw new ArgumentException(
string.Format(
CultureInfo.CurrentCulture, Resources.RunbookParameterCannotBeSerializedToJson,
runbookParameter.Key));
CultureInfo.CurrentCulture, Resources.RunbookParameterValueRequired, runbookParameter.Key));
}
}
else if (runbookParameter.Value.IsMandatory.HasValue && runbookParameter.Value.IsMandatory.Value)

if (filteredParameters.Count != parameters.Count)
{
throw new ArgumentException(
string.Format(
CultureInfo.CurrentCulture, Resources.RunbookParameterValueRequired, runbookParameter.Key));
string.Format(CultureInfo.CurrentCulture, Resources.InvalidRunbookParameters));
}
}

if (filteredParameters.Count != parameters.Count)
{
throw new ArgumentException(
string.Format(CultureInfo.CurrentCulture, Resources.InvalidRunbookParameters));
}


return filteredParameters;
}

Expand Down
1 change: 1 addition & 0 deletions src/Automation/Automation/help/New-AzAutomationRunbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ Valid values are:
- PowerShellWorkflow
- GraphicalPowerShellWorkflow
- Graph
- Python2
The value Graph is obsolete.
It is equivalent to GraphicalPowerShellWorkflow.
Expand Down
9 changes: 8 additions & 1 deletion src/Automation/Automation/help/Start-AzAutomationRunbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ PS C:\>Start-AzAutomationRunbook -AutomationAccountName "Contoso17" -Name "Runbk

This command starts a runbook job for the runbook named Runbk01 in the Azure Automation account named Contoso17.

### Example 2: Start a runbook job and wait for results
### Example 2: Start a Python 2 runbook job with parameters
```
PS C:\>Start-AzAutomationRunbook -AutomationAccountName "Contoso17" -Name "RunbkPy01" -ResourceGroupName "ResourceGroup01" -Parameters @{"Key1"="ValueForPosition1";"Key2"="ValueForPosition2"}
```

This command starts a runbook job for the Python 2 runbook named RunbkPy01 in the Azure Automation account named Contoso17 with "ValueForPosition1" as the first positional parameter and "ValueForPosition2" for the second one.

### Example 3: Start a runbook job and wait for results
```
Start-AzAutomationRunbook -AutomationAccountName "Contoso17" -Name "Runbk01" -ResourceGroupName "ResourceGroup01" -MaxWaitSeconds 1000 -Wait
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Management.CognitiveServices.dll-Help.xml
external help file: Microsoft.Azure.PowerShell.Cmdlets.CognitiveServices.dll-Help.xml
Module Name: Az.CognitiveServices
ms.assetid: 11D5BFDF-5E5D-46B2-9F9B-A0524EFA1B42
online version: https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/get-azcognitiveservicesaccount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Management.CognitiveServices.dll-Help.xml
external help file: Microsoft.Azure.PowerShell.Cmdlets.CognitiveServices.dll-Help.xml
Module Name: Az.CognitiveServices
ms.assetid: 73B1EB7E-568E-44E8-993A-91678B7D8AEE
online version: https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/get-azcognitiveservicesaccountkey
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Management.CognitiveServices.dll-Help.xml
external help file: Microsoft.Azure.PowerShell.Cmdlets.CognitiveServices.dll-Help.xml
Module Name: Az.CognitiveServices
ms.assetid: 386F09F0-2EEC-4B55-825C-F2E88D3B60AA
online version: https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/get-azcognitiveservicesaccountskus
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Management.CognitiveServices.dll-Help.xml
external help file: Microsoft.Azure.PowerShell.Cmdlets.CognitiveServices.dll-Help.xml
Module Name: Az.CognitiveServices
online version: https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/get-azcognitiveservicesaccounttype
schema: 2.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Management.CognitiveServices.dll-Help.xml
external help file: Microsoft.Azure.PowerShell.Cmdlets.CognitiveServices.dll-Help.xml
Module Name: Az.CognitiveServices
online version: https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/get-azcognitiveservicesaccountusage
schema: 2.0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Management.CognitiveServices.dll-Help.xml
external help file: Microsoft.Azure.PowerShell.Cmdlets.CognitiveServices.dll-Help.xml
Module Name: Az.CognitiveServices
ms.assetid: A2B4ACC1-6F53-47DE-A2D4-831E8AC89A5C
online version: https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/new-azcognitiveservicesaccount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Management.CognitiveServices.dll-Help.xml
external help file: Microsoft.Azure.PowerShell.Cmdlets.CognitiveServices.dll-Help.xml
Module Name: Az.CognitiveServices
ms.assetid: E0819A61-157A-4DFD-B492-09C8F1C38E18
online version: https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/new-azcognitiveservicesaccountkey
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Management.CognitiveServices.dll-Help.xml
external help file: Microsoft.Azure.PowerShell.Cmdlets.CognitiveServices.dll-Help.xml
Module Name: Az.CognitiveServices
ms.assetid: 87A79215-5688-474D-822A-6B84B3D10E3F
online version: https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/remove-azcognitiveservicesaccount
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
external help file: Microsoft.Azure.PowerShell.Cmdlets.Management.CognitiveServices.dll-Help.xml
external help file: Microsoft.Azure.PowerShell.Cmdlets.CognitiveServices.dll-Help.xml
Module Name: Az.CognitiveServices
ms.assetid: 11E2D82A-1DF1-4E19-8328-44674641D1BB
online version: https://docs.microsoft.com/en-us/powershell/module/az.cognitiveservices/set-azcognitiveservicesaccount
Expand Down
4 changes: 4 additions & 0 deletions src/Compute/Compute/Compute.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Strategies\ComputeRp\Images.json" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(StorageToolsPath)Adapters\ARM.Storage.Common.2017_10_01\ARMStorageProvider.cs" Link="Common\ARMStorageProvider.cs" />
<Compile Include="$(StorageToolsPath)Adapters\ARM.Storage.Common.2017_10_01\ARMStorageService.cs" Link="Common\ARMStorageService.cs" />
Expand Down
Loading

0 comments on commit a3e3a4f

Please sign in to comment.