如何实施嵌套部署

时间:2018-02-22 00:14:48

标签: azure azure-resource-manager

我有Azure ARM父模板,它嵌套了Microsoft.Automation/automationAccounts的部署,而Configurations部署了嵌套资源configuration。我能够成功部署整个模板一次,实际上在自动化帐户中创建了configuration。我在自动化帐户中手动删除了WorkerNodeDSCConfiguration并尝试再次运行模板,但根本不再触发此嵌套部署。没有错误,只是这个嵌套部署在历史记录中根本没有显示出来。我认为ARM认为自上次成功以来它不需要部署或不确定。可能是什么问题?

这是模板的相关部分。任何ScaleSet都没有触发嵌套部署 { "type": "Microsoft.Compute/virtualMachineScaleSets", "name": "[variables('namingInfix')]", "location": "[resourceGroup().location]", "apiVersion": "[variables('computeApiVersion')]", "dependsOn": [ "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]", "[concat('Microsoft.Network/applicationGateways/', variables('appGwName'))]", "[concat('Microsoft.Network/loadBalancers/', variables('loadBalancerName'))]", "WorkerNodeDscConfiguration" ], "sku": { "name": "[parameters('vmSku')]", "tier": "Standard", "capacity": "[parameters('instanceCount')]" }, "properties": { "overprovision": "false", "singlePlacementGroup": "true", "upgradePolicy": { "mode": "Automatic" }, "virtualMachineProfile": { "licenseType": "[parameters('LicenseType')]", "storageProfile": { "osDisk": { "caching": "ReadWrite", "createOption": "FromImage" }, "dataDisks": [], "imageReference": "[variables('imageReference')]" }, "osProfile": { "computerNamePrefix": "[variables('namingInfix')]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]" }, "networkProfile": { "networkInterfaceConfigurations": [ { "name": "[variables('nicName')]", "properties": { "primary": "true", "ipConfigurations": [ { "name": "[variables('ipConfigName')]", "properties": { "subnet": { "id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'), '/subnets/', variables('subnetName'))]" }, "loadBalancerBackendAddressPools": [ { "id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/loadBalancers/', variables('loadBalancerName'), '/backendAddressPools/', variables('bePoolName'))]" } ], "loadBalancerInboundNatPools": [ { "id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/loadBalancers/', variables('loadBalancerName'), '/inboundNatPools/', variables('natPoolName'))]" } ], "ApplicationGatewayBackendAddressPools": [ { "id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/applicationGateways/', variables('appGwName'), '/backendAddressPools/', variables('appGwBePoolName'))]" } ] } } ] } } ] }, "extensionProfile": { "extensions": [ { "name": "Microsoft.Powershell.DSC", "properties": { "autoUpgradeMinorVersion": true, "typeHandlerVersion": "2.72", "type": "DSC", "publisher": "Microsoft.Powershell", //"forceUpdateTag": "[parameters('DSCExtensionTagVersion')]", "settings": { "configurationArguments": { "RegistrationKey": { "UserName": "PLACEHOLDER_DONOTUSE", "Password": "[parameters('registrationKey')]" }, "RegistrationUrl": "[parameters('registrationUrl')]", "NodeConfigurationName": "swarmHost", "RebootNodeIfNeeded": true, "ConfigurationMode": "ApplyAndAutoCorrect" } } } } ] } } } }, { "name": "swarmmanagerdeployment", "type": "Microsoft.Resources/deployments", "apiVersion": "2016-09-01", "dependsOn": [], "properties": { "mode": "Incremental", "templateLink": { "uri": "[concat(parameters('_artifactsLocation'), '/', variables('swarmmanagerdeploymentTemplateFolder'), '/', variables('swarmmanagerdeploymentTemplateFileName'), parameters('_artifactsLocationSasToken'))]", "contentVersion": "1.0.0.0" }, "parameters": { "swarmmanager1Name": { "value": "[parameters('swarmmanager1Name')]" }, "swarmmanager1VmSize": { "value": "[variables('swarmmanager1VmSize')]" }, "adminUsername": { "value": "[parameters('adminUsername')]" }, "adminPassword": { "value": "[parameters('adminPassword')]" }, "dockerswarmstorageaccountName": { "value": "[variables('dockerswarmstorageaccountName')]" }, "dockerswarmstorageaccountType": { "value": "[parameters('dockerswarmstorageaccountType')]" }, "swarmmanager1NicName": { "value": "[variables('swarmmanager1NicName')]" }, "swarmmanagerpublicIPName": { "value": "[variables('swarmmanagerpublicIPName')]" }, "swarmmanager1SubnetRef": { "value": "[variables('swarmmanager1SubnetRef')]" }, "swarmmanager1ImagePublisher": { "value": "[variables('swarmmanager1ImagePublisher')]" }, "swarmmanager1ImageOffer": { "value": "[variables('swarmmanager1ImageOffer')]" }, "windowsOSVersion": { "value": "[parameters('windowsOSVersion')]" }, "swarmmanager1StorageAccountContainerName": { "value": "[variables('swarmmanager1StorageAccountContainerName')]" }, "swarmmanager1OSDiskName": { "value": "[variables('swarmmanager1OSDiskName')]" }, "swarmmanagerpublicIPDnsName": { "value": "[variables('swarmmanagerpublicIPName')]" }, "RegistrationKey": { "value": "[parameters('registrationKey')]" }, "RegistrationUrl": { "value": "[parameters('registrationUrl')]" }, "LicenseType": { "value": "[parameters('LicenseType')]" }, "_artifactsLocationSasToken": { "value": "[parameters('_artifactsLocationSasToken')]" }, "_artifactsLocation": { "value": "[parameters('_artifactsLocation')]" }, "privateKey": { "value": "[parameters('privateKey')]" }, "serverCert": { "value": "[parameters('serverCert')]" }, "CACert": { "value": "[parameters('CACert')]" } } } }, { "name": "WorkerNodeDscConfiguration", "type": "Microsoft.Resources/deployments", "apiVersion": "2017-05-10", "resourceGroup": "[parameters('automationAccountRGName')]", "dependsOn": [], "properties": { "mode": "Incremental", "template": { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.1", "resources": [ { "apiversion": "2015-10-31", "location": "[resourceGroup().location]", "name": "[parameters('automationAccountName')]", "type": "Microsoft.Automation/automationAccounts", "properties": { "sku": { "name": "Basic" } }, "tags": { }, "resources": [ { "name": "swarmhost", "type": "configurations", "apiVersion": "2018-01-15", "location": "[resourceGroup().location]", "dependsOn": [ "[concat('Microsoft.Automation/automationAccounts/', parameters('AutomationAccountName'))]" ], "properties": { "state": "Published", "overwrite": "true", "Source": { "type": "uri", "value": "[parameters('WorkerNodeDSCConfigURL')]" } } }, { "name": "[guid(resourceGroup().id, deployment().name)]", "type": "Compilationjobs", "apiVersion": "2015-10-31", "tags": {}, "dependsOn": [ "[concat('Microsoft.Automation/automationAccounts/', parameters('AutomationAccountName'))]", "[concat('Microsoft.Automation/automationAccounts/', parameters('AutomationAccountName'),'/Configurations/swarmhost')]" ], "properties": { "configuration": { "SwarmManagerURI": "[reference('swarmmanagerdeployment').outputs.returnedIPAddress.value]" } } } ] } ] } } }

class ViewController: UIViewController {

    @IBOutlet var backroundView: UIView!
    @IBOutlet weak var viewContainingTableView: UIView!
    @IBOutlet weak var topView: UIView!
    @IBOutlet weak var navigationBar: UINavigationBar!

    override func viewDidLoad() {
        super.viewDidLoad()
        //Change the corner radius to your liking
        viewContainingTableView.layer.cornerRadius = 25
        //Make the backround of your 'navigation controller' transparent
        topView.backgroundColor = UIColor.white.withAlphaComponent(0.0)
        //Declare a gradient
        let gradient: CAGradientLayer = CAGradientLayer()
        //Set the two colors of your gradient
        gradient.colors = [UIColor.purple.cgColor, UIColor.red.cgColor]
        //Set it's location
        gradient.locations = [0.0 , 1.0]
        gradient.startPoint = CGPoint(x: 0.0, y: 0.0)
        gradient.endPoint = CGPoint(x: 1.0, y: 1.0)
        gradient.frame = CGRect(x: 0.0, y: 0.0, width: self.view.frame.size.width, height: self.view.frame.size.height)
        self.backroundView.layer.insertSublayer(gradient, at: 0)
        //self.view.layer.insertSublayer(gradient, at: 0)
    }
}

enter image description here

1 个答案:

答案 0 :(得分:1)

很难分辨出发生了什么,但你可以通过更改某些vmss属性(例如,更改其他内容并运行模板)来验证是否有某些事情发生。它会将其恢复为模板中的内容。自动化帐户的东西可能相当棘手,因为我认为它不会触发编译工作,因为guid是相同的,资源已经存在。你需要每次都提供一个新的guid(ARM无法帮助你,你需要在外部进行一些随机化)。通常,我更喜欢使用powershell来配置与ARM相比的自动化帐户。

您还可以通过查看其时间戳来验证是否正在触发嵌套部署,它应该更改(并且将会更改)。资源始终已部署,但根据您的具体情况,其属性可能保持不变。