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

Updated templates to use symbolicName.id instead of resourceId - Part 2 #3780

Merged
merged 2 commits into from
Jul 30, 2021

Conversation

bhsubra
Copy link
Contributor

@bhsubra bhsubra commented Jul 27, 2021

Fixes #3501

Updated templates to use symbolicName.id instead of resourceId

@bhsubra bhsubra requested review from anthony-c-martin, AamirAllaq, majastrz and MarcusFelling and removed request for AamirAllaq July 27, 2021 06:54
@@ -53,18 +67,18 @@ resource loadBalancerExternal 'Microsoft.Network/loadBalancers@2020-11-01' = {
name: 'name'
properties: {
frontendIPConfiguration: {
id: resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', 'name', 'name')
id: 'id'
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were a bunch of these broken down to just "id"? Shouldn't all of these reference symbolic name of existing resource?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry should have left a comment earlier.
I thought this wasn't a valid one-Microsoft.Network/loadBalancers/frontendIPConfigurations

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same about the other ones I updated in this PR. Let me know if I am missing something.

@bhsubra bhsubra requested a review from MarcusFelling July 28, 2021 02:29
Comment on lines 2 to 13
resource vnet 'Microsoft.Network/virtualNetworks@2021-02-01' existing = {
name: /*${1:'name'}*/'name'
}

resource /*${2:'subnet'}*/subnet 'Microsoft.Network/virtualNetworks/subnets@2021-02-01' existing = {
parent: vnet
name: /*${3:'name'}*/'name'
}

resource /*${4:backendAddressPool}*/backendAddressPool 'Microsoft.Network/loadBalancers/backendAddressPools@2021-02-01' existing = {
name: /*${5:'loadBalancerExternal/loadBalancerBackEndPool'}*/'loadBalancerExternal/loadBalancerBackEndPool'
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense to include this in the snippet itself - most of the time I'd expect the user to already have references to these resources.

I'd expect the snippet to be either:

          subnet: {
            id: /*${5:subnetRef}*/subnetRef.id
          }

Or:

          subnet: {
            id: /*${5:subnetId}*/subnetId
          }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't include the snippet, then we'll have to do below(include single quotes) to avoid errors:

subnet: {
   id: /*${5:'subnetId'}*/'subnetId'
}

We expect user to remove quotes and update the reference. Is that correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we'd want to keep the quotes in the snippet - does it matter whether or not the snippet itself is error-free? I feel like it would be better to cater to the snippet user rather than the snippet author, and I can't think of any scenarios where quotes would be desirable for an id field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm my understanding was we wanted to keep the snippet error-free.

As part of #2944, I even added test to enforce this

public void VerifySnippetTemplatesAreErrorFree(CompletionData completionData)

Correct me if I am wrong.

Adding @MarcusFelling and @majastrz as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, removed referenced snippets:
c4c04eb

Also, included quotes as part of snippet placeholder:
image

properties: {
frontendIPConfiguration: {
id: resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', /*${2:'name'}*/'name', /*${3:'name'}*/'name')
id: 'id'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I think the original approach was optimal - resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', /*${2:'name'}*/'name', /*${3:'name'}*/'name')

Unfortunately I don't think there's a nice way to simplify this - as I think you mentioned on another comment, this isn't a real resource; it's a means of self-referencing properties within a single resource body that Microsoft.Network created to fit their scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the change you suggested above here as well:
c4c04eb

enableFloatingIP: false
idleTimeoutInMinutes: 5
probe: {
id: resourceId('Microsoft.Network/loadBalancers/probes', /*${2:'name'}*/'name', /*${12:'name'}*/'name')
id: 'id'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - unfortunately I don't think we have a way to avoid the original syntx.

Copy link
Contributor Author

@bhsubra bhsubra Jul 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops I forgot to add placeholder here. So I am guessing we want here(per your below comment):
/*${12:'probesId'}*/'probesId'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the change you suggested in above comment:
c4c04eb

containedResources: [
resourceId('Microsoft.OperationalInsights/workspaces/views', /*${3:'logAnalyticsWorkspace'}*/'logAnalyticsWorkspace', /*${4:'logAnalyticsSolution'}*/'logAnalyticsSolution')
/*${5:'id'}*/'id'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can go with one of either:

/*${5:viewRef}*/viewRef.id

Or:

/*${5:viewId}*/viewId

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated here:
c4c04eb

@bhsubra bhsubra requested a review from anthony-c-martin July 28, 2021 17:29
Copy link
Member

@anthony-c-martin anthony-c-martin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@bhsubra bhsubra merged commit 7319b37 into main Jul 30, 2021
@bhsubra bhsubra deleted the dev/bhsubra/Fix3501Part2 branch July 30, 2021 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Snippets should encourage use of symbolicName.id where possible instead of using resourceId
3 participants