Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect fix for 'use-parent-property' warning with blobContainer and fileShare #16455

Open
StephenWeatherford opened this issue Feb 21, 2025 · 0 comments
Assignees
Milestone

Comments

@StephenWeatherford
Copy link
Contributor

StephenWeatherford commented Feb 21, 2025

param storageAccountName string = toLower(take('stg${uniqueString(resourceGroup().id, deployment().name)}', 24))
param blobContainerName string = 'blobcontainer${uniqueString(resourceGroup().id, deployment().name)}'

param fileShareName string = 'fileshare${uniqueString(resourceGroup().id, deployment().name)}'

resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
  name: storageAccountName
  location: resourceGroup().location
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  properties: {
    accessTier: 'Hot'
  }
}

resource blobContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
  name: '${storageAccount.name}/default/${blobContainerName}'
  properties: {
    publicAccess: 'None'
  }
}

resource fileShare 'Microsoft.Storage/storageAccounts/fileServices/shares@2022-09-01' = {
  name: '${storageAccount.name}/default/${fileShareName}'
  properties: {
    shareQuota: 100
  }
}

Gives these warnings:

Image

Use quick fix on the blobContainer and fileShare resources, and you get this:

resource blobContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
  parent: storageAccount
  name: 'default/${blobContainerName}'
  properties: {
    publicAccess: 'None'
  }
}

resource fileShare 'Microsoft.Storage/storageAccounts/fileServices/shares@2022-09-01' = {
  parent: storageAccount
  name: 'default/${fileShareName}'
  properties: {
    shareQuota: 100
  }
}

with these errors:

Image

	"message": "The property \"parent\" expected a value of type \"Microsoft.Storage/storageAccounts/blobServices\" but the provided value is of type \"Microsoft.Storage/storageAccounts@2022-09-01\".",
	"message": "Expected resource name to not contain any \"/\" characters. Child resources with a parent resource reference (via the parent property or via nesting) must not contain a fully-qualified name.",
	"message": "The property \"parent\" expected a value of type \"Microsoft.Storage/storageAccounts/fileServices\" but the provided value is of type \"Microsoft.Storage/storageAccounts@2022-09-01\".",
	"message": "Expected resource name to not contain any \"/\" characters. Child resources with a parent resource reference (via the parent property or via nesting) must not contain a fully-qualified name.",

EXPECTED: Not sure, but possibly one of:

  1. better fix (is creating blobServer/fileService the only posible fix?)
  2. no warning
  3. ??

Here's the version that fully works (using copilot, multiple iterations, adding blobService and fileService resources)

resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2022-09-01' = {
  parent: storageAccount
  name: 'default'
}

resource blobContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2022-09-01' = {
  parent: blobService
  name: blobContainerName
  properties: {
    publicAccess: 'None'
  }
}

resource fileService 'Microsoft.Storage/storageAccounts/fileServices@2022-09-01' = {
  parent: storageAccount
  name: 'default'
}

resource fileShare 'Microsoft.Storage/storageAccounts/fileServices/shares@2022-09-01' = {
  parent: fileService
  name: fileShareName
  properties: {
    shareQuota: 100
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

3 participants