Understanding and Using Project BICEP - The NEW Azure Deployment Technology

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Every single one of this dude's video covers is just him figuring out how best to get his arms into the picture. He must have been absolutely delighted when Bicep was revealed. Hah.

👍︎︎ 22 👤︎︎ u/x0n 📅︎︎ Mar 09 2021 🗫︎ replies

I continue to believe that ARM is a bad idea from a development perspective and the Pulumi approach of wrapping the CLI is a much better alternative (although I fully admit I'm not sure if the CLI is using ARM under the covers) - Bicep doesn't really solve my big problems with ARM, it just makes it slightly less insane.

Big json documents are just not great to develop with.

👍︎︎ 4 👤︎︎ u/mdnbcfpr 📅︎︎ Mar 09 2021 🗫︎ replies

Ms should just buy hashi Corp and call it a day. Bicep is still complex where terraform is simple, English like structure.

👍︎︎ 2 👤︎︎ u/thesaintjim 📅︎︎ Mar 11 2021 🗫︎ replies

How the hell have I never heard of Pulumi before?!?!? This looks amazing at first glance.

👍︎︎ 1 👤︎︎ u/BenDaBuilder 📅︎︎ Mar 10 2021 🗫︎ replies
Captions
hey everyone in this video i want to talk about a huge cosmic level occurrence um in this world we have these cosmic level events these alignments these convergences that most likely will never happen in our lifetime for example we just had the conjunction of jupiter and saturn something not last seen for 800 years but that just seems a very common occurrence compared to what i'm going to talk about today and that's really this alignment of my training and azure to this new technology project bicep nice to keep a straight face i'm quite impressed so my goal for this video is to really go through project bicep um what it is why we want to use it really where it came from i've been promising this video for a while i said once it hits version dot three because dot three is really this production ready arm template parity release which we now have so if we take a step back for a second and as always if this is useful please like subscribe comment and share so we think about azure and i always draw this picture i can kind of think about well azure is this set of capacity all throughout the world many different regions on that capacity we build many different services compute storage network machine learning huge ranges of services and the way we interact with that is through kind of this azure resource manager and that's really what drives all of our interactions be it through a rest api powershell cli whatever and i can use all of those different things to create resources but really behind the scenes everything is stored in this configuration format of json i can actually go and look and if we were to go and look at resources.azure.com i can head over and say well let's look at my subscriptions let's look at my dev subscription let's look at my resource groups let's just kind of pick one of these i can see the resource providers that give me things like storage accounts and virtual networks and then within here i can see hey look there's a storage account and i can see this json format is how the resources are actually defined i can see things will like the sku the sku has a name it has a tier there's a name for example of the storage account so this is how the resources are actually stored under the covers i can even go to the portal i can look at any resource i want and you actually see under automation for really anything you have this option to export template and that will actually create a json template of that resource so once again i can go to the same resource and i can see export template and once again here is the json that defines that resource so under the covers everything is in this arm json format so we have this arm json and this is really designed about being a configuration format it's great for the system to be able to utilize now the best way i can think about is actually provisioning resources is by creating an arm template and then i basically submit that to the azure resource manager i can submit it for a restful call i can use the azcli powershell whatever and the benefits i get here are numerous firstly this is declarative what i'm doing is this is what i want the end state to be i'm not telling it how to do it i want a storage account for example if i was to look at a very basic template if i go and look at my files i've got storage account with containers file you can see i have this json file and what i'm basically doing is i'm saying hey look i want a storage account it's got a certain sku type and it's got a name and i want this thing i want this created and that's that's great so i can actually go through here and i could just deploy this template now right now if i was to look at the resource group this is going to deploy to just so you can kind of prove there's no kind of smoke and mirrors going on it's empty so what i can do is i can deploy that arm template so that's not going to go through and it's going to look and say well what's there right now what is the desired state in that json template and as picard would always say make it so so it's this declarative i just have to say well what do i want it to actually be now i can just keep re-running that so a great other thing is it's item potent i i can just keep re-running that same template if the reality matches the state it's not going to do anything but it's a great way to tell well is it that state i can go and do things like we'll detect drift it lets me do infrastructure as code i'm defining those resources as code and because it's as code what's super powerful here is i can do things like version control very commonly we're going to have something like some kind of git repository where i'm going to store that template to actually use it's very common in my ci cd pipelines the first thing it will ever do is actually call that template to make sure the resources are actually as i want them now we can see now that finished you can see how it went through it did that deployment the portal can take sometimes 30 seconds to catch up but hey look it's there there's the storage account and i can also see it created a container because within my json file what i actually had in here was hey yes i want you to create a storage account and i want you to create a container as well so it did those things and one of the things about this is it is declarative i can pass parameters i can have parameter files which are json files i can do things like what if so here i'm going to deploy it again but i'm going to say hey what if i now say i want the storage account type to be grs we can see at the bottom it's looking at well okay what's the reality what's the desired end state so now it's saying how do i want it to be grs what is it right now and it's going to show me well actually what i'm going to need to do is change it from lrs to grs see that at the bottom and it would just make that so so these are these are fantastic this is just absolutely awesome and one of the other nice things i get with my arm templates is i'm showing kind of just deploying to arm but one of the first things it actually does is a pre-flight and what that pre-flight does is it looks at the entire template looks at things like what are my quotas what are the capabilities and says will it work or not if i was going to create 50 vms and you had quota for 25 and say hey look this is not going to work let's stop it now other technologies won't they'll just go and create 25 and then fail so that pre-flight is actually a super useful capability so all i've said so far is that how fantastic these armed json files are i've talked about things like well how great i that what if capability to see well what would it do i can confirm i have those great parameter files so if i had for example a test environment a qa environment and a live environment i can use the same template it's immutable it's not going to change and the only thing that would be different is i'd have a different parameter file i'd have a parameter for test a parameter of qa a parameter for live but the actual template would be the same there's no risk of it changing going through those environments so why am i talking about bicep the challenge is this arm.json file is really a configuration language it's not really designed to be taught and user friendly like a typical programming language if we actually go back and look at it it's very very verbose if i actually go and say well let's look at this thing well there's lots of brackets everywhere there's oh there's a schema version there's content i have these parameters it's big it's very long it's kind of hard to read i have to use special parameters hey it's a parameter hey it's a variable hey there's resources i have to add depends on say okay well this container depends on the storage account that tells arm well okay i have to create the storage account first so while json is absolutely phenomenal in terms of a technology with that declarative nature that item potency that infrastructure is it's really not very nice for me as a human being to offer now there are things to help i already showed well from the portal i can export out a json template i can go to github and in github there's a massive library of getting started there's templates around creating storage accounts and creating virtual machines kind of the list really goes on but it's still just not that friendly bicep is designed to actually be a language we can work with we can actually program into but again i'm not forgetting about the powerful arm template so when we think about bicep is bisect kind of sits here i create my bicep file and essentially i transpile it into an arm template which then goes through so i get all the benefits of those arm templates but now i as a human don't have to worry about that fairly ugly arm json syntax i can now write in this very nice bicep bicep language because there's great tooling when you think about typescript transpiles to javascript this is the same kind of idea bicep is really designed around being able to be programmed there's fantastic tooling around this i'm going to focus on vs code and the extension there to be able to write these bicep files but it's transpiling it's going to create an arm template it sits on top of arm templates so as soon as functionality is in an arm template in arm it's going to be available in bicep as well straight away it just sits on top of it it's not going to be a delay anything i can do in an arm template i can do in bicep now initially what i had to do is i would actually have to do a bicep build so i would manually kind of have my bicep file i would build it to create the json file and then i would kind of use those az [Music] kind of cli commands or power shell or rest whatever to actually deploy it but now with version.3 and above i can use those same kind of az and powershell commands directly against the bicep it will compile it transpile it into an arm template in memory so i never see a json file on disk and send it to the arm so it's still using the arm i just don't see that template on the file system anymore and the huge thing here really is that it's just a much more friendly format i could quickly show this so if we actually go over so here i showed you this kind of very big storage account with container i can decompile so if i run this command it's doing a best efforts to decompile that json file into an actual bicep file so this is now the bicep file and what you'll notice is it's just a lot friendlier it's a lot easier to read um it's just referencing things like parameters directly not using special parameter keywords or anything else it's much cleaner as a human being i can kind of look at this and understanding it a lot easier than trying to work with a json template but again i get all of the goodness of those arm templates those what-ifs those confirms those pre-flight checks it's still all of that capability i'm getting with my bicep okay key point arm is not going anywhere again it sits on top of arms so i still have the arm templates and actually one of the things that's happening is because of bicep they're actually making the arm templates even better some of the challenges that have been there for a while are actually getting cleaned up because of the way bicep interacts with it so arm is always going to be there it's just bicep is removing my need to worry about that arm format i'm going to focus on my bicep file another key point if you use things like terraform there's a state file so essentially what happens is between kind of my desired state and reality they have this kind of state file and things like terraform need it because terraform worked with different cloud providers on premises things so they need some common format to track well what's reality it's not easy for them to just look at what's reality the challenge with the stateful is maintaining it if i have multiple people deploying i have to make sure that state file is somewhere shared they can all get to something happens to the state file there can be some pain involved bicep does not use a state file it does not need it bicep is aimed at azure arm templates are aimed at azure when it's doing a what if when it's working out the drift when it's working out what it has to do it's comparing my desired state to reality there is no in-between state file i have to try and work out it's always comparing to reality so what do i need to get these wonderful new things so it's the bicep today today is not really integrated with the portal it's not in the cloud shell just yet but i was expected to be there very very soon remember i can export templates from the portal the arm and decompile it into a bicep file i can use things like a z group export i can use the export az resource group from powershell to create those arm templates and then i could decompile it but if we think about going forward things like template stacks which are the replacement for blueprints the evolution of blueprints those will start using bicep i would imagine fairly soon so what tooling do i need to start using bicep well firstly if we jump over we're going to go to bicep and what we'll actually do is we will install the bicep cli so i can install this for example for the windows installer there's ones for mac os there's linux so this is actually going to get me bicep installed on my machine so it's like that bicep executable now one thing i will kind of stress to you um if i run mmsis.cpl no not that wrong one sorry i meant sysdm all right let's run sysdm i want to look at my path aerial system so cpl what it's going to do when i install bicep is it's adding it to your path so if i go and look at my environment variables and look at my user path what you'll actually notice is it's added here bicep cli now i had an earlier version installed which was still present on the system it was in like a dot bicep folder which was a higher entry in the path which meant it got used first so i went and deleted that old path from my path variable and actually deleted the folder so it's going to install bicep onto your machine and it's going to add it into your path so i now have the bicep engine so that's great now the next part is now i actually in my kind of dev environment i can think about okay in my machine i've kind of installed the bicep engine now if i'm using the azcli there's actually a special version of this now that actually supports the bicep so if it's version 2.20 and above i actually don't need to install bicep azcli will automatically pull down a self-contained version and use it if i'm using the powershell az module with nx version 5.6.0 that does actually link to the bicep in the path so i have to bicep installed and then version 5.6 of powershell so if i look over onto my machine and let's see what i have in my bicep demo well notice i can check my version of bicep bicep dash v and great i am 0.3.1 that's where i want to be then i can check what version of the powershell az module do i have and i'm writing 5f.6.0 fantastic can i go and check what the latest one is for the az i need 2.20 or above and i've got 2.20 so i'm all good in terms of the versioning on there now you'll notice i am actually in vs code so then what you also want is this bicep extension the bicep extension does not require that bicep engine to be installed on the box it just natively has kind of the understanding of the language this vs code extension will auto update but that's what's going to give me the ability to get really a lot of that very friendly authoring experience through bicep like the autocomplete suggestions of really what i need now the first thing i'm going to recommend to get the tooling in place is really go through the bicep tutorial it's phenomenal it's like i think seven pages of steps is going to introduce all of the core things creating your first template and deploying it it's going to go through variables parameters modules looping expression conditions decompiling it's going to cover all of that stuff so once you've got the environment set up my recommendation would actually be just go through that tutorial that's going to be the best way to actually start learning bicep and actually getting going with it but it would be remiss if i didn't at least show this what we're going to do is create a very very simple bicep file and just see what some of that experience actually is so over here in my vs code now you'll notice remember i had that bicep fold that it created but there were a few kind of ugly things about what it did kind of out of the box one of the big ones here is well it still has this depends on which normally i do not need and it's doing that because it's not actually referencing any part of the storage account so what we'll see is if we create this from scratch i don't need depends on in my bicep file so i'm going to close down that json file and what we're going to do is we're just going to create a brand new file so we're going to say new file and we'll just call it storage dot bicep so now i'm in my empty file now the first thing i'm going to want to do is have some parameters now it has intellisense so i'm going to say hey i want a parameter i want to be able to pass a location in it's going to be a string and now what i'm going to do is by default i'm going to give it a value and i'm going to use an expression so i'm going to actually look at the resource group notice i'm just hitting tab and the resource group has properties one of them is location so i'm just going to use by default the location of the resource group i'm deploying to great also i'm just going to add another parameter which is going to be the name of my storage account it's going to be a string again and i'm just going to set that to sa savio sus07 fantastic now i also want a storage account type so i'm going to do pram type string again equals and we'll say standard underscore lrs so these are just things that i'm setting some default values for but i could override them now for some of these things there are for example only certain allowed values there might be certain limits on what it can be for example the storage account name has to have a minimum of three characters and a maximum of 24. so i can actually add modifiers i could say things like hey um the min notice it's tab complete min length is three and i just put this ahead of the actual parameter the max length is 24. super easy well actually for the storage account time there's a list of allowed values so once again here i could do well hat allowed and then just add in an array and i'm way too lazy to retype all of those in so in this case i can just steal those from this other thing that it generated before so i can just say hey over here my list have allowed so i said what are the actual allowed values that i have for this so great i have three parameters that i've set default values for but i can override them i can override them by setting them as parameters on the actual command line when i call it i could pass a json configuration file so the bicep file does not have a different parameter file format so i have these json parameter files i can use the same json parameter files to bicep when i deploy it doesn't have its own native parameter file format it's going to use those same json parameter files where i had hey slightly different values for test and qa and live i can use those same files maybe at a different sql server or resource group to apply as i move through the different environments okay so now i actually want to create a resource so to create a resource it's super super easy intellisense is absolutely my friend here so i start typing and it says oh resource tab now what i'm going to do now is give it a basically a symbolic link this is kind of a a friendly name a symbolic name for the resource it is not the name of the resource in azure it's just a name that i can use throughout the bicep file to reference it so i'm going to have this symbolic name so i'm just going to call it um st account storage account and then it has to have a resource type now notice straight away intellisense has given me a whole list of things why i want a storage account so i'm just going to start typing storage and straight right now it's got me down to storage accounts i'm going to hit tab to get the latest api version for storage accounts now i have to set the properties so i'll do equals notice it's telling me how you need kind of the curly braces i'm just going to hit tab and now i'm ready now i can hit control space so control space is showing me straight without typing anything hey look here are some of the key things john you need okay well name looks like a good one and that actually shows me notice it's required now remember what i did here is i have name as a parameter up here but i don't have to do anything like special say hey parameter name i can literally just it's saying hey do you want name yes so that attribute name i'm populating from the parameter name okay what else do i need okay well i can say okay location my location once again i have a variable for that sorry a parameter for that so i'm going to say well my location is location then i know i need a kind so i type k there's kind and it's going to show me all the different types of storage account so i'm going to have a storage v2 next i need a skew so again on s and then it knows well actually there's different properties within the skew so it's curly braces and control space oh okay name and tier name is required so i'll have name and my name it gives me all of those different options but remember i actually have this as a parameter my type so what i will do here is just say i want it to be my type and that's it really what was my level of skill there uh i could hit control space and type in blob it did everything else for me and that's what's so powerful that intellisense as i'm using this nvs code makes it so so simple to actually create these things and at that point i could basically be done let's just go a couple of steps further i want to create a container in that storage account that then i'll see kind of that depends behavior so if we go back over to here again here we go so now i want another resource remember so okay so i want another resource this time i'm going to call it um i'm just going to call it my container i'll be very boring and the type well i know it's part of a blob service so i'll type blob services and it's going to be a container it's doing something slightly weird this time let's do this again so i know it's a blob services there we go and there's that container down there so i'll hit tab there we go so now it's showing me hey containers i'm creating it of this particular type and once again i just have to put in the attributes control space okay i need a name that's required it's showing me hey the name is actually required and for the name okay now i want to use the storage account so remember we have this symbolic name so what i'm going to now do is create an expression but also as part of that is if we try to create strings normally in a resource template i have to kind of do things like concat and do these fairly ugly things with bicep i have this great string interpolation where i can just basically combine those things together super super easily so what i'm going to do now is for the name well i'm going to reference my storage account symbolic name so i'll just do dollar and squiggly bracket and i'll say hey look there's my storage account i typed s dot and i'm going to reference here the name and then i'm going to put it in the default and then maybe i'll just call it images so it's going to create a container called images in my storage account and because it's referencing an attribute of the storage account it knows it depends upon it now i might say actually i don't really like that so instead what i could do is i could add variables i could add a variable called container name and i'm going to set that to images and then once again i can use this nice string interpolation capability and just do dollar squiggly brackets um container name put something there and i'm done and finally let's output the id of the storage account so i can have absolutely as we would expect output and again it's a symbolic name um the storage id is a string and it equals storage account id and that's it so you can see here so i have a number of parameters uh by default i'm getting the location the resource group i have a storage account name i'm setting a default and i'm having some kind of modifies it minimum maximum i've got a list of allowed values for the storage account type i create a variable images and then i'm just creating a storage account and then creating a container in that storage account so it depends upon it and i can save that now what i'm going to do is i'm going to build it now i do not have to do this i'm only doing this to show you the json it's actually going to create so what i'm going to do now is build that storage and then we can see over here i now have a storage json file so it's taken the bicep and it spat out a json file so it's got the variables look how much bigger it is it's just really not that friendly but i've got my storage account same parameters type and look what it's done it's added a depends on for the container it's going to create because i reference the container the storage account from the container so it knows hey i actually depend on that now i'm going to delete that i'm not going to leave that around so it doesn't actually need that storage json file so that's gone so now let's actually deploy it so what i'm going to do over here is i've got my storage bicep file so that's all finished and we're going to go and actually deploy now because i'm running that version 5.6 i can deploy directly from the bicep i can use those same a z and powershell commands directly against the bicep remember it's going to transpile it into a json file in memory and submit it to arm so it's still going to do those preflights i don't have to have some json file actually on the file system and again there's no state file involved in this so if we actually go and look where i'm going to deploy this to let's jump over look at my resource groups and i have an empty bicep demo resource group and now what i'm going to do is remember i'm going to deploy that bicep file so notice here i'm actually just referencing the bicep file and the resource group i want to deploy it to i'm using the regular az resource group deployment i want to use remember that's exactly the same one as i used with a json file so i'm just going to run that f8 so now it's going through it's compiling that in memory to a json file it's looking at what's my desired state in the bicep file what is reality well reality remember is there's nothing there there's nothing it could it has right now and it's going to work out okay well what do i need to do to make that desired state the reality so now it's going to actually go through it's going to create the storage account it's going to create so it's finished notice it has my outputs so it outputted the id as i requested and i can see hey look there's the location which is location the resource group and everything else and then within about 30 seconds it will show up in the portal right there already so there's a storage account and hopefully there's my container so it just worked but i could order the same features as just a regular template i can for example here override parameters on the command line or i could pass it a different parameter file with different values i can still use what if so let's actually run this again saying hey i want it to be grs this time but just give me a what if tell me what you would do so that's going to tell me hey what i would do at this point is well i know reality right now remember is lrs that's what we actually had inside so we know it's lrs right now and i'm telling you i want you to be grs so here we can see hey what i would do is change the sku name from lrs to grs and there's some stuff on the container images as well let's combine this az so let's use azcli instead i'm going to now do the same what if using the azcli now watch what it's doing notice straight away installing bicep cli v0.3.1 it does not need bicep installed on the box whereas the powershell references the bicep i have installed on my machine it has to be in the path azcli does not require that azcli brings down a self-contained version that it can just leverage and now once again it's told me hey what i would do is hey guess what i'm going to change from los to gos and let's actually do it then let's just prove i can be totally interoperable with those things so remember right now that storage account is lrs all i've done is i've changed my desired state in my bicep by essentially overriding a parameter to now say hey i want it to be grs and again that could be a parameter file that json parameter format and what i'm now saying is hey i want it to be grs it's showing me because i did dash c dash c means confirm it show me this is what i'm gonna do i'm gonna change it to grs do you want that yes go ahead so in here now just say yes and go so it's gonna make my desired state a reality on the system it's going to convert it from an lrs to a grs now think about if i was doing that imperatively if i was just writing a powershell script i'd have to say well does it exist okay if it doesn't exist create it if it does exist was a different command to maybe change the type that's the beauty of this declarative nature is i'm just saying this is what i want reality to be you work out what you have to do to actually make that the real world and that's why when i think about using these technologies again your ci cd pipelines when you have that pipeline one of the first things you're typically going to do is hey now i'll call my bicep file to make sure the core resource is there be it my app service plan or my functions or my sql database whatever it might already be there great i'm just making sure it is and then i can deploy my code run my tests and everything else if i need to change the reality change what i need i don't care what's there just go and make this the reality so now according to this it has finished succeeded so if we go back and actually look again if i hit refresh notice remember what we're looking at is this kind of replication if i hit refresh well now it's grs so again my desired state changed i'm good to go now that's a very very simple demo as i said there's loops there's conditions um there are modules and what you really want to do is kind of go through that tutorial modules are phenomenal because if you think about hey i had this bicep file and i'm going to store them in my git repos so what i'll end up with over time is a whole bunch of bicep files maybe it's a bicep file to create a storage account maybe it's a bicep file to create an app service plan all these different files that create resources i get this library and now they become modules and now when i actually want to do a deployment i can say hey i'm going to create a new main bicep file and basically reference the different files i need using this special module parameter let's just show you that quick so if i jump over again to the tutorial page it's got great information on hey using those resource declarations conditions existing all that stuff but then it talks about modules so that i wouldn't have to change my bicep file at all but now i could just reference it from a different bicep file i can override parameters if i want to and now i use it so i can get this whole library of things that i can now leverage um i can even do things like set scope so i can change the scope as i do deployments to maybe be a subscription so i can actually create a resource group in my bicep file maybe i want to target a different resource group but this is really the point now they're very easy to alter you you saw that kind of intellisense experience using visual studio but there is still a huge github repo you can actually go to the bicep docs examples and over here just like arm templates there's a whole bunch of 101s all these different things i want to create a simple windows vm there's my bicep file hey look i have parameters once again i have some variables and then oh look i'm creating a storage account probably for the diagnostics then i'm creating a public ip address then i'm creating a network security group um then i actually create a network interface then i create a vm and i just have the core values and attributes i actually need so it's just so much friendlier to actually use and understand so yes i can start from scratch and they're kind of really are nice to author it's a programming language of great tooling but there's still a load of things to help me so with all that said what does this mean what is the future using arm templates today or maybe using terraform today if you're using something today like terraform and it works for you phenomenal keep using it maybe you're multi-cloud maybe your hybrid if terraform works stay on that bicep is just another option now if i was using arm templates i would recommend you move to bicep because remember you're still getting all the benefits things like this pre-flight all of these capabilities you're still going to get it's going to make your experience a lot lot nicer so i think what we'll see is if you are kind of around that arm template world or maybe you're only using terraform maybe for azure and maybe all i didn't like the json format but i said maybe i'm going to reevaluate that what i think we'll see is today you probably have arm templates for example in your git repo that you call it start your ci cd you won't do that instead of having arm templates you'll have bicep files and you'll call the bicep file at the start of your pipeline to make sure the resources are as you want as i talked about blueprints today use arm templates to actually deploy resources template specs to the evolution of that template specs will start using bicep so this is really just i think where we're going to go to if you're using arm templates you're going to migrate to using bicep if you're using something else well just reevaluate maybe why i was using the sam kels if it's a multi-cloud or multi-thing great carry on doing it if it was just because arm templates were ugly hey maybe i will go and reevaluate that that was it definitely go through that tutorial it's phenomenal it's going to teach you everything you need to really be successful but as always i appreciate you watching and good luck you
Info
Channel: John Savill's Technical Training
Views: 16,421
Rating: undefined out of 5
Keywords: azure, azure cloud, project bicep, bicep, azure template, arm templates, json template, intellisense, deployment
Id: _yvb6NVx61Y
Channel Id: undefined
Length: 43min 9sec (2589 seconds)
Published: Tue Mar 09 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.