{"id":6610,"date":"2023-03-21T10:44:22","date_gmt":"2023-03-21T02:44:22","guid":{"rendered":"https:\/\/www.jameseduard.com\/?p=6610"},"modified":"2023-03-21T10:44:22","modified_gmt":"2023-03-21T02:44:22","slug":"how-to-install-openssl-module-in-azure-automation","status":"publish","type":"post","link":"https:\/\/www.jameseduard.com\/?p=6610","title":{"rendered":"How to install OpenSSL Module in Azure Automation"},"content":{"rendered":"\n\n\n<p class=\"wp-block-paragraph\">OpenSSL is a widely-used open source tool for secure communication over the internet. It allows you to create and manage SSL\/TLS certificates, encrypt and decrypt files, and perform other cryptographic tasks. Azure Automation is a cloud-based automation service in Azure that allows you to automate the management of your resources. In this blog post, we&#8217;ll show you how to use OpenSSL in Azure Automation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you begin, you need to have the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>An Azure subscription<\/li>\n\n\n\n<li>An Azure Automation account<\/li>\n\n\n\n<li>A basic understanding of PowerShell<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Installing the OpenSSL Module<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The first step is to install the OpenSSL module in your Azure Automation account. To do this, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to your Azure Automation account in the Azure portal.<\/li>\n\n\n\n<li>Click on &#8220;Modules&#8221; in the left-hand menu.<\/li>\n\n\n\n<li>In the &#8220;Modules&#8221; blade, click on &#8220;Browse gallery&#8221;.<\/li>\n\n\n\n<li>Search for &#8220;OpenSSL&#8221; and select the &#8220;OpenSSL&#8221; module.<\/li>\n\n\n\n<li>Click on &#8220;Import&#8221; to import the module into your Automation account.<br><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.jameseduard.com\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-21-at-11.26.16-AM-1050x550.png\" alt=\"\" class=\"wp-image-6623\"\/><figcaption class=\"wp-element-caption\">In the &#8220;Modules&#8221; blade, click on &#8220;Browse gallery&#8221;.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.jameseduard.com\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-21-at-11.28.35-AM-1050x546.png\" alt=\"\" class=\"wp-image-6624\"\/><figcaption class=\"wp-element-caption\">Search for &#8220;OpenSSL&#8221; and select the &#8220;OpenSSL&#8221; module.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.jameseduard.com\/wp-content\/uploads\/2023\/03\/Screenshot-2023-03-21-at-11.23.11-AM-1050x550.png\" alt=\"\" class=\"wp-image-6620\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a PowerShell Runbook<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once you have the OpenSSL module installed, you can create a PowerShell runbook to use it. Follow these steps to create a PowerShell runbook:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to your Azure Automation account in the Azure portal.<\/li>\n\n\n\n<li>Click on &#8220;Runbooks&#8221; in the left-hand menu.<\/li>\n\n\n\n<li>Click on &#8220;Create a runbook&#8221; and select &#8220;PowerShell&#8221; as the runbook type.<\/li>\n\n\n\n<li>Give your runbook a name and click on &#8220;Create&#8221;.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Writing a PowerShell Script<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Next, you need to write a PowerShell script that uses the OpenSSL module. Here is an example script that generates a private key and a self-signed certificate:<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">Import-Module OpenSSL\n\n$pass = ConvertTo-SecureString \"yourpassword\" -AsPlainText -Force\n$thumbprint = \"\"\n\n# Generate a private key\n$key = New-OpenSSLKey -Passphrase $pass -Algorithm RSA -KeyLength 2048 -OutFilePath \"C:\\OpenSSL\\private.key\"\n\n# Generate a self-signed certificate\n$cert = New-OpenSSLCertificate -Key $key -Passphrase $pass -Subject \"CN=yourdomain.com\" -NotBefore (Get-Date) -NotAfter (Get-Date).AddYears(1) -OutFilePath \"C:\\OpenSSL\\certificate.crt\"\n\n# Get the certificate thumbprint\n$certObject = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2\n$certObject.Import(\"C:\\OpenSSL\\certificate.crt\")\n$thumbprint = $certObject.Thumbprint\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This script generates a private key and a self-signed certificate using the OpenSSL module. It then imports the certificate and gets the certificate thumbprint.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the Runbook<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once you have written your PowerShell script, you can test your runbook by clicking on the &#8220;Test pane&#8221; button in the top menu. This will allow you to run your script and see the output.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Publishing the Runbook<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If your script works correctly, you can publish your runbook to make it available for use. To do this, click on the &#8220;Publish&#8221; button in the top menu.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using OpenSSL in Azure Automation allows you to automate the management of SSL\/TLS certificates, encrypt and decrypt files, and perform other cryptographic tasks in the cloud. By following the steps in this blog post, you can get started using OpenSSL in Azure Automation today.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks to my team Khairul Azri &amp; Gabriel cheers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenSSL is a widely-used open source tool for secure communication over the internet. It allows you to create and manage SSL\/TLS certificates, encrypt and decrypt files, and perform other cryptographic tasks. Azure Automation is a cloud-based automation service in Azure that allows you to automate the management of your resources. In this blog post, we&#8217;ll<\/p>\n","protected":false},"author":1,"featured_media":6613,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52,47],"tags":[87,607,956],"class_list":["post-6610","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","category-how-tos","tag-automation","tag-openssl","tag-runbook"],"_links":{"self":[{"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/posts\/6610","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6610"}],"version-history":[{"count":0,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=\/wp\/v2\/posts\/6610\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jameseduard.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}