TheDude
TheDude

Reputation: 1531

Set-AzureRmApiManagementPolicy : ValidationError: Resource was modified since last retrieval

When I try to call the Set-AzureRmApiManagementPolicy PowerShell commandlet to update a policy in Azure API Management, I get the following error:

Set-AzureRmApiManagementPolicy : ValidationError: Resource was modified since last retrieval.

This error only occurs when a policy already exists. If I delete the policy and re-run it, then it works fine. So, there's some strange issue with updating the policy once it's already there. I know that this SHOULD work since I'm able to get this running if I call into Login-AzureRmAccount ahead of time and login. Then the updating of an existing policy works. It seems to be related to the way I'm authenticating with the Api Management REST API. I'm using a certificate method of authenticating which is why I don't need to call Login-AzureRmAccount. Any ideas?

Upvotes: 2

Views: 598

Answers (1)

TheDude
TheDude

Reputation: 1531

It turns out the issue is a result of a bug in the older "2014-02-14" api-version. The PowerShell commandlet (Set-AzureRmApiManagementPolicy) is basically compiling down into a simple REST call which uses the 2014-02-14 api-version. I checked the version of the PowerShell module AzureRm.ApiManagement by calling Get-Module -ListAvailable

Since the AzureManagement module is bundled with the Octopus platform I'm using, there's no way for me to directly update it. Therefore, I've made the decision to simply scrap the idea of using a PowerShell commandlet altogether and simply call into the Azure Management REST API directly. Problem solved.

Upvotes: 1

Related Questions