-
Notifications
You must be signed in to change notification settings - Fork 757
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
Add "Insert Resource" to the Bicep.exe file, not just VS code extension #5696
Comments
My suggestion is to name this command
|
Any news regarding this? |
Interesting suggestion! Would there be any objection to building this into AzCLI & AzPwsh instead of the Bicep CLI? e.g. something like: az bicep insert-resource --ids '<id>' --out-file 'res.bicep' Conceptually this is also quite similar to the export + decompile sinppet here - apart from simplicity, are there any benefits to having "Insert Resource" in the CLI instead of using this snippet? |
Not any objection, as long the binary does the job, altrough I would be a big fan of seeing this in the Bicep CLI binary. Reason for not using the already existing export + decompile is that quite frankly often you don't have the JSON or you don't want to download the JSON and manually decompile it. Most people are just interacting with the resources directly by clickops or devops. Having this It will enable teams that do not have their Azure stack in neither |
The two commands are not functionally the same. The VSCode bicep insert resource is scoped to a single resource, whereas For example, pointing @description('Generated from /subscriptions/xxxx-xxxx-xxxx/resourceGroups/myRG')
resource myRG 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: 'myRG'
location: 'eastus'
tags: {}
properties: {}
} Note this is a bicep file for the Resource Group, not any objects in it. The Az command your proposing does this:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccounts_mystorageacct_name": {
"type": "String"
}
},
"resources": [
{
"apiVersion": "2021-09-01",
"kind": "StorageV2",
"location": "eastus",
"name": "[parameters('storageAccounts_mystorageacct_name')]",
"properties": {
"accessTier": "Cool",
"allowBlobPublicAccess": true,
"allowCrossTenantReplication": true,
"allowSharedKeyAccess": true,
"defaultToOAuthAuthentication": false,
"minimumTlsVersion": "TLS1_2",
"publicNetworkAccess": "Enabled",
"supportsHttpsTrafficOnly": true
},
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"type": "Microsoft.Storage/storageAccounts"
}
],
"variables": {}
} Which is a complete ARM template for the objects inside the RG, not the RG itself. |
Thanks @ChristopherGLewis, that's one of the things I was hoping to get at with my questioning. You're right - ARM's export is more limited in that it can only be used to fetch resources inside a resource group, and has no support for subscription, tenant, extension resources etc. I do still feel like conceptually this would fit better as an |
Please know, it is actually possible to extract a single resource from a given resource group like this: #export the resource to a ARM template
az group export -g MyResourceGroupName --resource-ids "resourceId" >myresource.json |
Is your feature request related to a problem? Please describe.
The "Insert Resource" command is excellent but only works in VS code as a function of the VS Code extension. Please add this to the bicep executable as
Describe the solution you'd like
By adding this feature to the Bicep.exe file, scripting the output of many objects can be simplified.
IMPORT
might be the wrong action word for the EXE. We havebuild
andDecompile
, maybe something more likeGET
orREAD
.The text was updated successfully, but these errors were encountered: