How to add Certificate in your Azure VM using Startup task
Here are the detailed steps:
1. Create a folder name Startup in your Project
2. Add your certificate in this folder (In this case I have added MyCert.cer)
3. Create a command batch file name addcert.cmd in the same folder and as following command:
certutil -addstore root Startup\MyCert.cer
If you want to delete a certificate in the startup task use the command as below:
certutil -delstore My <certificate_name>
Note: Certificate_Name can be take from CN entry.
At this point your VS2010 project will look like as below:
4. Now add the following code in your Service Definition (ServiceDefinition.csdef):
<Startup> <Task commandLine="Startup\AddCert.cmd" executionContext="elevated" taskType="simple"> </Task> </Startup>
That’s it!! Now you can verify the selected certificate is included in the certificate root store by RDP to your Azure VM.