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

Refactor and remove use of ArmSnippits.jsonc #844

Closed
Tracked by #748
Cairn23 opened this issue Jul 11, 2020 · 7 comments
Closed
Tracked by #748

Refactor and remove use of ArmSnippits.jsonc #844

Cairn23 opened this issue Jul 11, 2020 · 7 comments

Comments

@Cairn23
Copy link

Cairn23 commented Jul 11, 2020

The current working rely on the armsnippits.jsonc in order to formulate the basic template for the user to populate. The problem I see with this is that it's possible to then get out of sync with the scheme's. Would it not be better to only utilise the schema and the resource definitions. from my reading to date the convention to date is that if the definition name does not include and underscore its a piece of Azure compute that can be deployed. Those with the underscore are sub components .
eg in the Microsoft.web.json you have a Sites definition, than all the sub components are names sites_***.
Therefore from this you should be able to build as required, and also remove the dependency on the code snippets

@neilpeterson
Copy link
Contributor

Thanks for opening this issue @Cairn23. Are you suggesting that instead of using the static armsnippets.jsonc for providing snippet services we use something that dynamically creates snippets fro arm schemas?

We are considering what to do next with snippets, which may include a refactoring of the snippet source. Details / dicssion can be found in this issue: #748

@Cairn23
Copy link
Author

Cairn23 commented Jul 12, 2020

That's correct. It should be possible to create the required code from the schema's.
My thinking is that upon starting the tool, the schemas are loaded forming some form of map, and the key is the template type. when a user then creates a completely blank template, and adds a resource, the map is then used to form the dropdown of options. Once a compute type is selected it will then form the rest of the template resource contents. We have seen that its possible to do bits of this already as when you attempt to add a property the schemas are used for this, so this in effect making the whole think dynamic and will also require less support as it is possible the schema could change which will not match the snippets

@StephenWeatherford
Copy link
Contributor

We've discussed automatically generating snippets from schema, but it's not as simple as it sounds. It would work in many cases but will probably yield poor results in many others. It would still be nice to have the option available for ones we don't have more specific snippets for.

@alexgav How much work do you think that would be? And how successful do you think it would be?

@Cairn23
Copy link
Author

Cairn23 commented Jul 13, 2020

The schema should be the definition of whats is possible, so would be good to understand why you think it will yield poor results, unless you are indicating there are problems with the schemas

@neilpeterson neilpeterson mentioned this issue Jul 14, 2020
24 tasks
@neilpeterson
Copy link
Contributor

Adding some notes / thoughts for discussion.

Template reference documentation is created using autorest and the azureresourceschema plugin. Perhaps we can investigate this method for auto-generating snippets.

That said, some considerations:

Terseness

Consider is the verbosity / terseness of auto-generated snippets. For example, take a look at the auto-generated snippet in this doc vs. the current snippet.

        {
            "name": "aksCluster1",
            "type": "Microsoft.ContainerService/managedClusters",
            "apiVersion": "2020-02-01",
            "location": "[resourceGroup().location]",
            "properties": {
                "kubernetesVersion": "1.15.7",
                "dnsPrefix": "dnsprefix",
                "agentPoolProfiles": [
                    {
                        "name": "agentpool",
                        "count": 2,
                        "vmSize": "Standard_A1",
                        "osType": "Linux",
                        "storageProfile": "ManagedDisks"
                    }
                ],
                "linuxProfile": {
                    "adminUsername": "adminUserName",
                    "ssh": {
                        "publicKeys": [
                            {
                                "keyData": "keyData"
                            }
                        ]
                    }
                },
                "servicePrincipalProfile": {
                    "clientId": "servicePrincipalAppId",
                    "secret": "servicePrincipalAppPassword"
                }
            }
        }

I have spoken with many customers about this and preference is to start terse and layer on optional properties as desired. However on the flip side, we have received significant feedback on snippet coverage, autogenerated / verbose snippets may be a compromise.

Tab stops

Would we be able to intelligently add tab stops ideally with potential values? I do not use them much myself but they do add a nice polish.

Resource generalization

One of the things I'm keen on doing is adding some resource generalization. For example, if I add a storage account .via a snippet would I also add and reference a parameter for the name. This may be the same discussion as tab stops, but want to point out the specific feature.

@StephenWeatherford
Copy link
Contributor

StephenWeatherford commented Jul 14, 2020

Other considerations:

Best practices

Just filling in the available properties may not yield a resource with best practices

Multiple-resource snippets

Quite a few of our snippets create multiple resources

That said, I've never liked being in the business of owning snippets for other teams.

@jodavis
Copy link

jodavis commented Sep 8, 2020

We're tracking this as part of a larger Snippets effort, #748

@jodavis jodavis closed this as completed Sep 8, 2020
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants