Skip to main content

Resource Manager Template Deployment

 Hey Guys !! Today I created a number of resources in my Azure subscription. As I was creating the KeyVaults , I realized that this was a time spending exercise for me, because I was in need to have 6 KeyVaults, and each KeyVault there were around 5 secrets. And for each KeyVault I would have to assign the required permissions. These permission were with Users of AD, Objects of Deployments (Service Principal cretead in Azure Devops), and the Azure App Services by which these Key Vaults were need to be access. Then suddenly , I though that there should be way to reduce the time of resource creation.

I was aware that we can do it with the help of Azure Resource Manager templates. So I though , lets try Azure Resource Manager Template deployments.

I did google and after some doing some analysis, I was able to do it very well.

So Guys, I will update in todays session that How I was able to save my time with the help Azure Resource Manager Template Deploymnets. 

There are some steps that I followed for creating  the KeyVaults with template deploymnets. These steps can be used to deploy any resource, not even only for KeyValus.

So here are the Steps that I followed..


  1. Export a Template from existing resource. 
  2. Edit Template
  3. Deploy Template

Export Template

This export option is available in almost all resources. We can either Copy that template or we can download that template or we can add that Template in Library section. For me, I simply copy and paste the content of that template in a text file.



I realized that , each templates carries 3 important sections, which are 

  1. Parameters
  2. Variables 
  3. Resources




Paremeters : Parameter is some thing that is being passed as Value during the deploymnets
Varaibles: Variable is some thing in which we can store some values and can use it at multiple places in our Template.
Resources: Resources are the actual resources, which we are in need to create.

Edit Template

Once I had the template in text file, I found the parameter name along with its default value and it;s datatype.

    "parameters": {
        "vaults_MyProject_dev_name": {
            "defaultValue""MyProject-dev",
            "type""String"
        }

Here if you will see, than you will find that "vaults_MyProject_dev_name" this is the Paramter Name, which we can modify during the deploymnet.
I updated it's value to ,     "parameters": {
        "vaults_MyProject_dev_name": {
            "defaultValue""MyProject-qa",
            "type""String"
        }

Deploy Template


Now, I went to search section of Azure and typed "deploy", and there I found "Deploy a Custom Template" under the Services section. I clicked on that service.






















There I clicked on "Build your own template in the editor", pasted my updated template and Saved it.


After clicking on Save button , I found that I was able to change the values, which I found as Parameters in template. I provided the Resource Group name, and the Parameter value, I clicked on "Review+Create", and then on "Cretae" button.


I realized that in few minutes, KeyVault was ready but I got error as "BadRequest" for deployment/creation secrets.
Error message was "The parameter value is not specified."

I found that when we export a Template of KeyVault, it export the secret name but it does exports it Value. So We have to add the value by own.
I find the section of secret and added it's value. For me , it was some thing like this..

{
            "type""Microsoft.KeyVault/vaults/secrets",
            "apiVersion""2016-10-01",
            "name""[concat(parameters('vaults_MyProject_dev_name'), '/DBConnectionString')]",
            "location""eastus",
            "dependsOn": [
                "[resourceId('Microsoft.KeyVault/vaults', parameters('vaults_MyProject_dev_name'))]"
            ],
            "properties": {
                "attributes": {
                    "value": "MySecretValue",
                    "enabled"true
                }
            }
        }

After doing this , I was able to create KeyVault without any error.

I repeated the 3rd step "Template Deployment" for all my other keyVaults, and I was able to save my lots of time.

Thanks to Azure Resource Template deployments feature.

Comments

Post a Comment

Popular posts from this blog

Enable detailed Error in WebAPI Azure App Services

 Hey Guys !! Today we faced an issue in one of our Web API hosted in Azure as PaaS (Web App Services). We were not getting detailed error message , we were just getting message as  "Server Error in '/' Application. Runtime Error" To overcome this issue, we were in need to know the exact reason of issue, as because by default we can not get the detailed error message on web page. So, we did some changes in our web.config file. We just opened the web.config file from https://ourappiXYZ. scm.azurewebsites.net / To open the web.config file, we logged in with scm and clicked on "Debug Console" >> "CMD", as per below screen shot Then, we clicked on site folder and then "wwwroot" folder, and then edit the web.config file. In web.confif file, we added  <customErrors mode="Off" /> , inside  the   <system.web>   <system.web>     <customErrors mode="Off" />   </system.web> and then we added ...

Azure and DevOps

Hey Guys !! My name is Vineet. I am an IT professional with around 14 years of exp. I have worked in a number of technologies.  In my daily day to day activities, I realized that we do a lot of activities daily, but we never mention that what we learnt today. I thought that , we should mention it some where, so I though to create blogs. I just went to blogspot and thought , what should be the name of my blog. As now a days , I am workking on Azure stuff, so I thought lets start it from Azure it self, and created blog with name "AzureNDevops". In our technical life , whenever we got stuck we always go to google and tried to resolved that issue, but there are a number of situations in which even google does not work for your case, and you have to resolve it by own. And when we resolve it , we got some happiness and proudness some where in our self. This happiness becomes double and even more when you share it with some one. I am starting my blog to share the stories with World,...