public void MachineExtensions_Get() { _context = MockContext.Start(GetType().FullName); Initialize(); PopulateExtensions(); MachineExtension extension = _client.MachineExtensions.Get(RESOURCE_GROUP_NAME, MACHINE_NAME, CUSTOM_SCRIPT_EXTENSION_NAME); Assert.Equal(CUSTOM_SCRIPT_EXTENSION_NAME, extension.Name); Assert.Equal(_machine.Location, extension.Location); Assert.NotNull(extension.Settings); }
public async Task MachineExtensions_GetAsync() { _context = MockContext.Start(GetType().FullName); Initialize(); PopulateExtensions(); MachineExtension extension = await _client.MachineExtensions.GetAsync(RESOURCE_GROUP_NAME, MACHINE_NAME, DEPENDENCY_AGENT_EXTENSION_NAME).ConfigureAwait(false); Assert.Equal(DEPENDENCY_AGENT_EXTENSION_NAME, extension.Name); Assert.Equal(_machine.Location, extension.Location); Assert.Equal("Microsoft.Azure.Monitoring.DependencyAgent", extension.Publisher); }
private void PopulateExtensions() { // Create two extensions if (_isLinux) { MachineExtension extension = new MachineExtension { Location = _machine.Location, Settings = new Hashtable { { "commandToExecute", "echo 'hi'" }, }, TypeHandlerVersion = "2.1", Publisher = "Microsoft.Azure.Extensions", MachineExtensionType = "CustomScript", }; _client.MachineExtensions.CreateOrUpdate(RESOURCE_GROUP_NAME, MACHINE_NAME, CUSTOM_SCRIPT_EXTENSION_NAME, extension); extension = new MachineExtension { Location = _machine.Location, Publisher = "Microsoft.Azure.Monitoring.DependencyAgent", MachineExtensionType = "DependencyAgentLinux", }; _client.MachineExtensions.CreateOrUpdate(RESOURCE_GROUP_NAME, MACHINE_NAME, DEPENDENCY_AGENT_EXTENSION_NAME, extension); } else { MachineExtension extension = new MachineExtension { Location = _machine.Location, Settings = new Hashtable { { "commandToExecute", "echo 'hi'" }, }, TypeHandlerVersion = "1.10", Publisher = "Microsoft.Compute", MachineExtensionType = "CustomScriptExtension", }; _client.MachineExtensions.CreateOrUpdate(RESOURCE_GROUP_NAME, MACHINE_NAME, CUSTOM_SCRIPT_EXTENSION_NAME, extension); extension = new MachineExtension { Location = _machine.Location, Publisher = "Microsoft.Azure.Monitoring.DependencyAgent", MachineExtensionType = "DependencyAgentWindows", }; _client.MachineExtensions.CreateOrUpdate(RESOURCE_GROUP_NAME, MACHINE_NAME, DEPENDENCY_AGENT_EXTENSION_NAME, extension); } }
public async Task MachineExtensions_CreateOrUpdateAsync() { _context = MockContext.Start(GetType().FullName); Initialize(); const string extensionName = "custom"; MachineExtension extension = _isLinux ? new MachineExtension { Location = _machine.Location, Settings = new Hashtable { { "commandToExecute", "echo 'hi'" }, }, TypeHandlerVersion = "2.1", Publisher = "Microsoft.Azure.Extensions", MachineExtensionType = "CustomScript", } : new MachineExtension { Location = _machine.Location, Settings = new Hashtable { { "commandToExecute", "echo 'hi'" }, }, TypeHandlerVersion = "1.10", Publisher = "Microsoft.Compute", MachineExtensionType = "CustomScriptExtension", }; MachineExtension extensionFromCreate = await _client.MachineExtensions.CreateOrUpdateAsync(RESOURCE_GROUP_NAME, MACHINE_NAME, extensionName, extension).ConfigureAwait(false); Assert.Equal(extensionName, extensionFromCreate.Name); Assert.Equal(_machine.Location, extensionFromCreate.Location); Assert.Equal("echo 'hi'", ((JObject)extensionFromCreate.Settings).Value <string>("commandToExecute")); MachineExtension extensionFromGet = await _client.MachineExtensions.GetAsync(RESOURCE_GROUP_NAME, MACHINE_NAME, extensionName).ConfigureAwait(false); Assert.Equal(extensionName, extensionFromGet.Name); Assert.Equal(_machine.Location, extensionFromGet.Location); Assert.Equal("echo 'hi'", ((JObject)extensionFromGet.Settings).Value <string>("commandToExecute")); }
static void BuildConstructors(TypeBuilder typeBuilder, Type baseType, Type stateType, FieldInfo dispatcherField, Type triggerType) { TypeBuilder triggerTypeBuilder = triggerType as TypeBuilder; if (triggerTypeBuilder != null && !triggerTypeBuilder.IsCreated()) { triggerType = triggerTypeBuilder.CreateType(); } object initialState = MachineExtension.GetInitialState(baseType); var transitions = BuildTransitions(typeBuilder, baseType, stateType); var cInfos = baseType.GetConstructors(BF.Instance | BF.NonPublic | BF.Public); for (int i = 0; i < cInfos.Length; i++) { ILGenerator ctorGenerator = EmitBaseCtorCall(typeBuilder, cInfos[i]); CreateConstructor(ctorGenerator, stateType, initialState, triggerTypeBuilder, triggerType, dispatcherField, transitions ); } }
public async Task MachineExtensions_UpdateAsync() { _context = MockContext.Start(GetType().FullName); Initialize(); PopulateExtensions(); const string newCommand = "echo 'goodbye'"; MachineExtensionUpdate extensionUpdate = _isLinux ? new MachineExtensionUpdate { Settings = new Hashtable { { "commandToExecute", newCommand }, }, } : new MachineExtensionUpdate { Settings = new Hashtable { { "commandToExecute", newCommand }, }, }; MachineExtension extension = await _client.MachineExtensions.UpdateAsync(RESOURCE_GROUP_NAME, MACHINE_NAME, CUSTOM_SCRIPT_EXTENSION_NAME, extensionUpdate).ConfigureAwait(false); Assert.Equal(newCommand, ((JObject)extension.Settings).Value <string>("commandToExecute")); }
/// <summary> /// The operation to create or update the extension. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='name'> /// The name of the machine where the extension should be created or updated. /// </param> /// <param name='extensionName'> /// The name of the machine extension. /// </param> /// <param name='extensionParameters'> /// Parameters supplied to the Create Machine Extension operation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <MachineExtension> CreateOrUpdateAsync(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, name, extensionName, extensionParameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// The operation to create or update the extension. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// The name of the resource group. /// </param> /// <param name='name'> /// The name of the machine where the extension should be created or updated. /// </param> /// <param name='extensionName'> /// The name of the machine extension. /// </param> /// <param name='extensionParameters'> /// Parameters supplied to the Create Machine Extension operation. /// </param> public static MachineExtension CreateOrUpdate(this IMachineExtensionsOperations operations, string resourceGroupName, string name, string extensionName, MachineExtension extensionParameters) { return(operations.CreateOrUpdateAsync(resourceGroupName, name, extensionName, extensionParameters).GetAwaiter().GetResult()); }