Closed t-bzhan closed 1 year ago
@zhoxing-ms for awareness
@zhoxing-ms We're seeing this error now, "Profile.ExtendedProperties' is read-only and cannot be changed" when running our bicep modules to update the FrontDoor:
{
"code": "DeploymentFailed",
"message": "At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",
"details": [
{
"code": "BadRequest",
"message": "Property 'Profile.ExtendedProperties' is read-only and cannot be changed"
}
]
}
This works fine with the following az cli but fails within AzureDevOps tasks, so I'm not sure what needs fixing:
// Main.bicep
@description('The name of the Front Door endpoint to create. This must be globally unique.')
param endpointName string = 'shared-cds-frontdoor-premium-sb'
@description('The profileName becomes the Front Door UI name. This must be globally unique.')
param profileName string = 'FrontDoorPremiumNonProd'
@description('The name of the SKU to use when creating the Front Door profile.')
@allowed([
'Standard_AzureFrontDoor'
'Premium_AzureFrontDoor'
])
param skuName string = 'Standard_AzureFrontDoor'
resource profile 'Microsoft.Cdn/profiles@2022-11-01-preview' = {
name: profileName
location: 'Global'
sku: {
name: skuName
}
kind: 'frontdoor'
properties: {
originResponseTimeoutSeconds: 240
extendedProperties: {
}
}
}
resource endpoint 'Microsoft.Cdn/profiles/afdendpoints@2022-11-01-preview' = {
parent: profile
name: endpointName
location: 'Global'
properties: {
enabledState: 'Enabled'
}
}
param dom array = []
param org array = []
param orgG array = []
param rts array = []
resource customDomains 'Microsoft.Cdn/profiles/customdomains@2022-11-01-preview' = [ for domain in dom: {
parent: profile
name: domain.Name // 'cdsapi-cargilldigitalsolutions-com'
properties: {
hostName: domain.hostName // 'cdsapi.cargilldigitalsolutions.com'
tlsSettings: {
certificateType: 'ManagedCertificate'
minimumTlsVersion: 'TLS12'
}
}
}]
resource originGroup 'Microsoft.Cdn/profiles/origingroups@2022-11-01-preview' = {
parent: profile
name: orgG[0].Name // 'og-cds-api-service'
properties: {
loadBalancingSettings: {
sampleSize: 4
successfulSamplesRequired: 3
additionalLatencyInMilliseconds: 0
}
healthProbeSettings: {
probePath: '/'
probeRequestType: 'HEAD'
probeProtocol: 'Http'
probeIntervalInSeconds: 100
}
sessionAffinityState: 'Disabled'
}
}
resource origins 'Microsoft.Cdn/profiles/origingroups/origins@2022-11-01-preview' = [ for origin in org : {
name: origin.Name // 'cds-api-service'
parent: originGroup
properties: {
hostName: origin.HostName // 'cds-api-service.azurewebsites.net'
httpPort: 80
httpsPort: 443
originHostHeader: origin.HostHeader // 'cds-api-service.azurewebsites.net'
priority: 1
weight: 1000
enabledState: 'Enabled'
enforceCertificateNameCheck: true
}
}]
resource routesResource 'Microsoft.Cdn/profiles/afdendpoints/routes@2022-11-01-preview' = {
name: rts[0].Name
parent: endpoint
properties: {
cacheConfiguration: {
compressionSettings: {
isCompressionEnabled: false
contentTypesToCompress: []
}
queryStringCachingBehavior: 'IgnoreQueryString'
}
customDomains: [
{
id: customDomains[0].id
}
]
originGroup: {
id: originGroup.id
}
ruleSets: []
supportedProtocols: [
'Http'
'Https'
]
patternsToMatch: [
'/*'
]
forwardingProtocol: 'HttpsOnly'
linkToDefaultDomain: 'Enabled'
httpsRedirect: 'Enabled'
enabledState: 'Enabled'
}
}
// parameters.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"profileName": {
"value": "FrontDoorPremiumNonprod"
},
"skuName": {
"value": "Standard_AzureFrontDoor"
},
"endpointName": {
"value": "shared-cds-frontdoor-premium-sb"
},
"dom" : {
"value" : [
{
"Name" : "cdsapi-cargilldigitalsolutions-com",
"hostName" : "cdsapi.cargilldigitalsolutions.com"
}
]
},
"org" : {
"value" : [
{
"Name": "cds-api-service",
"HostName": "cds-api-service.azurewebsites.net",
"HostHeader": "cds-api-service.azurewebsites.net"
}
]
},
"orgG" : {
"value" : [
{
"Name" : "og-cds-api-service"
}
]
},
"rts": {
"value" : [
{
"Name": "r-cds-api-service"
}
]
}
}
} ```
Hi @t-bzhan,
if a new parameter such as --update-mode be added to indicate whether "PATCH" or "PUT" should be used, more codes need to be changed compared to adding new commands. In order to avoid bug bringing and be more convenient for users to use, we suggest adding a new command az resource patch
to support "PATCH" request for updating resource.
Could you please help to check if this solution meets your expectation?
Hi @t-bzhan, if a new parameter such as --update-mode be added to indicate whether "PATCH" or "PUT" should be used, more codes need to be changed compared to adding new commands. In order to avoid bug bringing and be more convenient for users to use, we suggest adding a new command
az resource patch
to support "PATCH" request for updating resource.Could you please help to check if this solution meets your expectation?
I think that is great, thanks so much!
Related command
az resource update --ids /subscriptions/27cafca8-b9a4-4264-b399-45d0c9cca1ab/resourcegroups/bo-private/providers/Microsoft.Cdn/profiles/migprofile101 --set identity.type=SystemAssigned --api-version 2022-11-01-preview --debug
Is your feature request related to a problem? Please describe.
From the diagnostic output, it looks like
az resource update
underlyingly will issue a "GET" request first and then issue a "PUT" instead of "PATCH" to service side.That might cause problems when the GET API returns read only properties (extendedProperties in below GET response), the following "PUT" might be rejected by backend service.
Describe the solution you'd like
Is it possible to add a new parameter such as --update-mode to indicate whether "PATCH" or "PUT" should be used.
Describe alternatives you've considered
Another way is CLI underlyingly check whether PATCH is supported by the resource, it will prefer "PATCH" and only use "PUT" as a fallback when updating resources.
Additional context
Command diagnostic output: