Skip to content
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
2 changes: 1 addition & 1 deletion src/ResourceManager/Aks/Commands.Aks.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="Hyak.Common" version="1.1.3" targetFramework="net452" />
<package id="Microsoft.Azure.Common" version="2.1.4" targetFramework="net452" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.1-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net452" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net452" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net452" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Analysis" version="2.0.4" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Authorization" version="2.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="3.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ DotNetFrameworkVersion = '4.7.2'
RequiredModules = @(@{ModuleName = 'Az.Profile'; ModuleVersion = '0.5.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.Automation.dll', '.\Microsoft.Azure.Management.ResourceManager.dll'
RequiredAssemblies = '.\Microsoft.Azure.Management.Automation.dll'

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CLRVersion = '4.0'
RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '5.8.0'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = '.\Microsoft.Azure.Management.Automation.dll','.\Microsoft.Azure.Management.ResourceManager.dll'
RequiredAssemblies = '.\Microsoft.Azure.Management.Automation.dll'

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Automation" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="2.0.0-preview" />
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,6 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Automation.3.4.0-preview\lib\net452\Microsoft.Azure.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ResourceManager.2.0.0-preview\lib\net452\Microsoft.Azure.Management.ResourceManager.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
using System.Management.Automation.Runspaces;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using AutomationManagement = Microsoft.Azure.Management.Automation;
using DscNode = Microsoft.Azure.Management.Automation.Models.DscNode;
using Job = Microsoft.Azure.Management.Automation.Models.Job;
using JobSchedule = Microsoft.Azure.Management.Automation.Models.JobSchedule;
using Schedule = Microsoft.Azure.Commands.Automation.Model.Schedule;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Internal.ResourceManager.Version2018_05_01;

namespace Microsoft.Azure.Commands.Automation.Common
{
Expand Down Expand Up @@ -799,128 +800,80 @@ public void RegisterDscNode(string resourceGroupName,
Model.AgentRegistration agentRegistrationInfo = this.GetAgentRegistration(
resourceGroupName,
automationAccountName);

var parameters = GetDSCDeploymenttemplateParameters(resourceGroupName,
automationAccountName,
azureVMName,
nodeconfigurationName,
configurationMode,
configurationModeFrequencyMins,
refreshFrequencyMins,
rebootFlag,
actionAfterReboot,
moduleOverwriteFlag,
azureVmResourceGroup,
location,
agentRegistrationInfo.Endpoint,
agentRegistrationInfo.PrimaryKey);

var armClient = AzureSession.Instance.ClientFactory.CreateArmClient<ResourceManagementClient>(azureContext, AzureEnvironment.Endpoint.ResourceManager);

var deployment = new Management.ResourceManager.Models.Deployment
var parameters = new ParametersObj
{
Properties = new Management.ResourceManager.Models.DeploymentProperties
ActionAfterReboot = new TemplateParameters
{
TemplateLink = new Management.ResourceManager.Models.TemplateLink(Constants.TemplateFile),
Parameters = parameters
Value = actionAfterReboot
},
AllowModuleOverwrite = new TemplateParameters
{
Value = moduleOverwriteFlag
},
ConfigurationFunction = new TemplateParameters
{
Value = Constants.ConfigurationFunction
},
ConfigurationMode = new TemplateParameters
{
Value = configurationMode
},
ConfigurationModeFrequencyMins = new TemplateParameters
{
Value = configurationModeFrequencyMins
},
Location = new TemplateParameters
{
Value = location
},
ModulesUrl = new TemplateParameters
{
Value = Constants.ModulesUrl
},
NodeConfigurationName = new TemplateParameters
{
Value = nodeconfigurationName
},
RebootNodeIfNeeded = new TemplateParameters
{
Value = rebootFlag
},
RefreshFrequencyMins = new TemplateParameters
{
Value = refreshFrequencyMins
},
RegistrationKey = new TemplateParameters
{
Value = agentRegistrationInfo.PrimaryKey
},
RegistrationUrl = new TemplateParameters
{
Value = agentRegistrationInfo.Endpoint
},
Timestamp = new TemplateParameters
{
Value = DateTimeOffset.UtcNow.ToString("o")
},
VmName = new TemplateParameters
{
Value = azureVMName
}
};

armClient.Deployments.CreateOrUpdate(azureVmResourceGroup, Guid.NewGuid().ToString(), deployment);

}
var armClient = AzureSession.Instance.ClientFactory.CreateArmClient<ResourceManagementClient>(azureContext, AzureEnvironment.Endpoint.ResourceManager);

private string GetDSCDeploymenttemplateParameters(string resourceGroupName,
string automationAccountName,
string azureVMName,
string nodeconfigurationName,
string configurationMode,
int configurationModeFrequencyMins,
int refreshFrequencyMins,
bool rebootFlag,
string actionAfterReboot,
bool moduleOverwriteFlag,
string azureVmResourceGroup,
string azureVmLocation,
string registrationEndPoint,
string registrationKey)
{
var template = new DeploymentTemplateParameters
{
ContentVersion = "1.0.0.0",
Schema = "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
Parameters = new ParametersObj {
ActionAfterReboot = new TemplateParameters {
Value = actionAfterReboot
},
AllowModuleOverwrite = new TemplateParameters
{
Value = moduleOverwriteFlag
},
ConfigurationFunction = new TemplateParameters
{
Value = Constants.ConfigurationFunction
},
ConfigurationMode = new TemplateParameters
{
Value = configurationMode
},
ConfigurationModeFrequencyMins = new TemplateParameters
{
Value = configurationModeFrequencyMins
},
Location = new TemplateParameters
{
Value = azureVmLocation
},
ModulesUrl = new TemplateParameters
{
Value = Constants.ModulesUrl
},
NodeConfigurationName = new TemplateParameters
{
Value = nodeconfigurationName
},
RebootNodeIfNeeded = new TemplateParameters
{
Value = rebootFlag
},
RefreshFrequencyMins = new TemplateParameters
{
Value = refreshFrequencyMins
},
RegistrationKey = new TemplateParameters
{
Value = registrationKey
},
RegistrationUrl = new TemplateParameters
{
Value = registrationEndPoint
},
Timestamp = new TemplateParameters
{
Value = DateTimeOffset.UtcNow.ToString("o")
},
VmName = new TemplateParameters
{
Value = azureVMName
}
}
};

var serializationSettings = new JsonSerializerSettings
var deployment = new Management.Internal.ResourceManager.Version2018_05_01.Models.Deployment
{
NullValueHandling = NullValueHandling.Ignore,
ContractResolver = new CamelCasePropertyNamesContractResolver()
Properties = new Management.Internal.ResourceManager.Version2018_05_01.Models.DeploymentProperties
{
TemplateLink = new Management.Internal.ResourceManager.Version2018_05_01.Models.TemplateLink(Constants.TemplateFile),
Parameters = parameters
}
};

var serializer = JsonSerializer.Create(serializationSettings);
var textWriter = new StringWriter();
serializer.Serialize(textWriter, template);
return textWriter.ToString();
Task.Run(() => armClient.Deployments.CreateOrUpdateWithHttpMessagesAsync(azureVmResourceGroup, Guid.NewGuid().ToString(), deployment)).Wait();
}


#endregion

#region compilationjob
Expand Down Expand Up @@ -1809,51 +1762,54 @@ private string GetNodeConfigurationListFilterString(string configurationName)
#endregion
}


internal class DeploymentTemplateParameters
{
[JsonProperty("$schema")]
public string Schema { get; set; }

public string ContentVersion { get; set; }

public ParametersObj Parameters { get; set; }
}

internal class ParametersObj
{
[JsonProperty("vmName")]
public TemplateParameters VmName { get; set; }

[JsonProperty("location")]
public TemplateParameters Location { get; set; }

[JsonProperty("modulesUrl")]
public TemplateParameters ModulesUrl { get; set; }

[JsonProperty("configurationFunction")]
public TemplateParameters ConfigurationFunction { get; set; }

[JsonProperty("registrationKey")]
public TemplateParameters RegistrationKey { get; set; }

[JsonProperty("registrationUrl")]
public TemplateParameters RegistrationUrl { get; set; }

[JsonProperty("nodeConfigurationName")]
public TemplateParameters NodeConfigurationName { get; set; }

[JsonProperty("configurationMode")]
public TemplateParameters ConfigurationMode { get; set; }

[JsonProperty("configurationModeFrequencyMins")]
public TemplateParameters ConfigurationModeFrequencyMins { get; set; }

[JsonProperty("refreshFrequencyMins")]
public TemplateParameters RefreshFrequencyMins { get; set; }

[JsonProperty("rebootNodeIfNeeded")]
public TemplateParameters RebootNodeIfNeeded { get; set; }

[JsonProperty("actionAfterReboot")]
public TemplateParameters ActionAfterReboot { get; set; }

[JsonProperty("allowModuleOverwrite")]
public TemplateParameters AllowModuleOverwrite { get; set; }

[JsonProperty("timestamp")]
public TemplateParameters Timestamp { get; set; }
}

internal class TemplateParameters
{
[JsonProperty("value")]
public object Value { get; set; }
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.Management.Automation" version="3.4.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="2.0.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.1-preview" targetFramework="net452" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just remove this altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm less concerned about doing that since these files (all .config files) will be removed in 2 weeks anyway. I just flat changed all Management.ResourceManager references to the same version (to be consistent).

</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="2.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Consumption" version="3.0.2" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.1-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="3.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.8.1" targetFramework="net452" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ContainerInstance" version="1.0.3-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.1-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Test.Framework" version="3.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ContainerRegistry" version="2.0.1" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.1-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Test.Framework" version="3.0.0" targetFramework="net452" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<package id="Microsoft.Azure.Management.Authorization" version="2.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.DataLake.Analytics" version="3.3.1-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.DataLake.Store" version="2.4.2-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.1-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="3.0.0" targetFramework="net452" />
Expand Down
Loading