1
votes

OK - I have a weird one.....

I've deployed Compilation Jobs via ARM Templates using the following code:

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "compile-settings": {
        "type": "object",
        "metadata": {
            "description": "These are settings for a DSC Compile"
        }
    },
    "tag-values": {
        "type": "object",
        "metadata": {
            "description": "These are the Tag values"
        }
    }
},
"resources": [
    {
        "name": "[parameters('compile-settings').name]",
        "type": "Microsoft.Automation/automationAccounts/compilationjobs",
        "apiVersion": "2015-10-31",
        "location": "Australia Southeast",
        "tags": "[parameters('tag-values')]",
        "dependsOn": [],
        "properties": {
            "configuration": "[parameters('compile-settings').configuration]",
            "parameters": "[parameters('compile-settings').parameters]"
        },
        "resources": []
    }
],
"outputs": {}

}

Because I'm developing at the moment. when I re-run the deployment I get the following error:

{ "code": "Conflict", "message": "Job with specified id already exists. Job id: cde3eb0e-e8e4-de3e-0eae-e4cde3eb0eae" }

Using resources.azure.com, I cannot find this resource, but I can find it when using PowerShell e.g.

Get-AzureRmResource -ResourceId "/subscriptions/{subscriptionId}/resourceGroups/rg-au-901/providers/Microsoft.Automation/automationAccounts/aa-au-901/compilationjobs/cde3eb0e-e8e4-de3e-0eae-e4cde3eb0eae" -ApiVersion "2015-10-31"

Result:

ResourceId : /subscriptions/{subscriptionId}/resourceGroups/rg-au-901/providers/Microsoft.Automation/automationAccounts/aa-au-901/compilationjobs/cde3eb0e-e8e4-de3e-0eae-e4cde3eb0eae ResourceName : aa-au-901/cde3eb0e-e8e4-de3e-0eae-e4cde3eb0eae ResourceType : Microsoft.Automation/automationAccounts/compilationjobs ResourceGroupName : rg-au-901 SubscriptionId : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx Properties : @{jobId=cde3eb0e-e8e4-de3e-0eae-e4cde3eb0eae; creationTime=2017-07-16T08:27:13.457+00:00; provisioningState=Suspended; status=Suspended; statusDetails=None; startTime=2017-07-16T08:28:01.74+00:00; endTime=; lastModifiedTime=2017-07-16T08:28:13.85+00:00; lastStatusModifiedTime=2017-07-16T08:28:13.85+00:00; exception=The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The term 'xStorage\xWaitforDisk' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.; parameters=; configuration=; runOn=; newNodeConfigurationBuildVersionRequired=False}

However, when I try to remove it using Remove-AzureRmResource with the Force parameter it fails:

Remove-AzureRmResource : The pipeline has been stopped. At line:1 char:1 + Remove-AzureRmResource -ResourceId "/subscriptions/xxxxxxxx-xxxx-xxxx ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Remove-AzureRmResource], PipelineStoppedException + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.RemoveAzureResourceCmdlet Remove-AzureRmResource : {"code":"MethodNotAllowed","message":"{\"Message\":\"The requested resource does not support http method 'DELETE'.\"}"} At line:1 char:1 + Remove-AzureRmResource -ResourceId "/subscriptions/xxxxxxxx-xxxx-xxxx ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Remove-AzureRmResource], ErrorResponseMessageException + FullyQualifiedErrorId : MethodNotAllowed,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.RemoveAzureResourceCmdlet

Help?

3
whats the question? you obviously cannot delete those if they don't support delete4c74356b41
Is there no way of deleting them?mrptsai
i would expect that to be the case, for instance there's no powershell cmdlet to delete them, only the get cmdlet4c74356b41
@mrptsai You could not delete these jobs. These jobs record log information and they have different job id. In your template, you should use different job id. Please refer to this link.Shui shengbao

3 Answers

1
votes

You could work around that with a powershell step to generate a GUID, or maybe omit the GUID so it generates one for itself.

Also, there's a powershell cmdlet to start a compilation job, that doesn't need a guid.

Start-AzureRmAutomationDscCompilationJob
0
votes

Based on my knowledge, you could not delete CompilationJob. When you execute the job again, it will regenerate a different Job id. You could use the following command to re-run Compilation Job

Start-AzureRmAutomationDscCompilationJob -ResourceGroupName "shui" -AutomationAccountName "shuitest" -ConfigurationName "dscDomainJoin"

More information please refer to this link.

If you want to delete all jobs, you need remove your DSC configurations.

0
votes

I actually released the answer was in the error. If the same GUID already existed, then I had a logic issue.

I found I wasn't passing the parent Deployment Name (which was always different) to the child deployment and the Unique String Function in the ARM Template wasn't generating a 'Unique' GUID.

The Resource in the Parent Template now has the following code in:

"name": "[concat('dscCompile-', toLower(uniqueString(deployment().name)))]"

The Child Template uses a variable and is then concatenated to create a Unique string to generate a GUID.

"deployment": "[concat('-', toLower(uniqueString(deployment().name)))]"

"name": "[concat('newGuid', copyIndex(), variables('deployment'))]",

Thanks to all who responded with your help and suggestions!