Skip to content

Commit 7e05149

Browse files
committed
Merge pull request #287 from safeermohammed/dev
Automation cmdlets bug fixes and updated with Automation SDK version 1.0.1
2 parents 7e77b73 + 1859795 commit 7e05149

File tree

11 files changed

+369
-4096
lines changed

11 files changed

+369
-4096
lines changed

src/Common/Commands.ScenarioTest/Resources/Automation/AutomationTests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Checks whether the first string contains the second one
1818
#>
1919

20-
$accountName='safeer'
20+
$accountName='account'
2121
$location = "East US"
2222

2323
function AssertContains

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/NewAzureAutomationCertificate.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Security.Permissions;
2020
using Microsoft.Azure.Commands.Automation.Model;
2121
using Microsoft.Azure.Commands.Automation.Common;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2223

2324
namespace Microsoft.Azure.Commands.Automation.Cmdlet
2425
{
@@ -71,7 +72,7 @@ public class NewAzureAutomationCertificate : AzureAutomationBaseCmdlet
7172
protected override void AutomationExecuteCmdlet()
7273
{
7374

74-
var createdCertificate = this.AutomationClient.CreateCertificate(this.AutomationAccountName, this.Name, this.Path, this.Password, this.Description, this.Exportable.IsPresent);
75+
var createdCertificate = this.AutomationClient.CreateCertificate(this.AutomationAccountName, this.Name, this.ResolvePath(this.Path), this.Password, this.Description, this.Exportable.IsPresent);
7576

7677
this.WriteObject(createdCertificate);
7778
}

src/ServiceManagement/Automation/Commands.Automation/Cmdlet/SetAzureAutomationCertificate.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Security.Permissions;
2020
using Microsoft.Azure.Commands.Automation.Model;
2121
using Microsoft.Azure.Commands.Automation.Common;
22+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2223

2324
namespace Microsoft.Azure.Commands.Automation.Cmdlet
2425
{
@@ -71,7 +72,7 @@ public class SetAzureAutomationCertificate : AzureAutomationBaseCmdlet
7172
protected override void AutomationExecuteCmdlet()
7273
{
7374

74-
var updateddCertificate = this.AutomationClient.UpdateCertificate(this.AutomationAccountName, this.Name, this.Path, this.Password, this.Description, this.Exportable);
75+
var updateddCertificate = this.AutomationClient.UpdateCertificate(this.AutomationAccountName, this.Name, this.ResolvePath(this.Path), this.Password, this.Description, this.Exportable);
7576

7677
this.WriteObject(updateddCertificate);
7778
}

src/ServiceManagement/Automation/Commands.Automation/Commands.Automation.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@
9292
<SpecificVersion>False</SpecificVersion>
9393
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.4.0.1\lib\net40\Microsoft.WindowsAzure.Management.dll</HintPath>
9494
</Reference>
95-
<Reference Include="Microsoft.WindowsAzure.Management.Automation">
96-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Automation.1.0.0\lib\net40\Microsoft.WindowsAzure.Management.Automation.dll</HintPath>
95+
<Reference Include="Microsoft.WindowsAzure.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
96+
<SpecificVersion>False</SpecificVersion>
97+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.Management.Automation.1.0.1\lib\net40\Microsoft.WindowsAzure.Management.Automation.dll</HintPath>
9798
</Reference>
9899
<Reference Include="Newtonsoft.Json">
99100
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
@@ -195,6 +196,7 @@
195196
<DesignTime>True</DesignTime>
196197
<DependentUpon>Resources.resx</DependentUpon>
197198
</Compile>
199+
<Compile Include="Common\RequestSettings.cs" />
198200
</ItemGroup>
199201
<ItemGroup>
200202
<Content Include="Microsoft.Azure.Commands.Automation.dll-help.xml">

src/ServiceManagement/Automation/Commands.Automation/Common/AutomationClient.cs

Lines changed: 149 additions & 95 deletions
Large diffs are not rendered by default.

src/ServiceManagement/Automation/Commands.Automation/Common/Constants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,7 @@ public class AutomationAccountState
5353

5454
public const int PsCommandValueDepth = 10;
5555

56+
public const string ClientRequestIdHeaderName = "x-ms-client-request-id";
57+
5658
}
5759
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Linq;
18+
using System.Text;
19+
using System.Threading.Tasks;
20+
using Microsoft.Azure.Commands.Automation.Common;
21+
using Microsoft.WindowsAzure.Management.Automation;
22+
23+
namespace Microsoft.Azure.Commands.Automation
24+
{
25+
public class RequestSettings : IDisposable
26+
{
27+
private readonly AutomationManagementClient client;
28+
29+
public RequestSettings(IAutomationManagementClient automationClient)
30+
{
31+
client = ((AutomationManagementClient)automationClient);
32+
client.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
33+
client.HttpClient.DefaultRequestHeaders.Add(Constants.ClientRequestIdHeaderName, Guid.NewGuid().ToString());
34+
}
35+
36+
public void Dispose()
37+
{
38+
client.HttpClient.DefaultRequestHeaders.Remove(Constants.ClientRequestIdHeaderName);
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)