title: Creating an Azure certificate in Python
body: <p>I'm using Python to automate the creation of an App Service Cerficate for my Azure application (an AKS cluster). One of the REST calls I need to make is described here:</p>
  
  <p><a href="https://docs.microsoft.com/en-us/rest/api/appservice/appservicecertificateorders/createorupdate" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/rest/api/appservice/appservicecertificateorders/createorupdate</a></p>
  
  <p>This describes the call that's needed to create an App Service Cerficate Order, the result of which is then passed on to the REST call to create the App Service Certificate.</p>
  
  <p>My problem is I can't figure out from the sparse documentation what is needed in the request body for this REST call. I've build a structure that looks like this:</p>
  
  <pre><code>request_body = {
      "location" : "eastus",
      "properties" : {
          "autoRenew" : true,
          "productType" : "StandardDomainValidatedSsl",
          "distinguishedName": "???",
          "csr": "???"
      }
  }
  </code></pre>
  
  <p>I've been unable to figure out what is needed for these last two fields. The csr field is described as "Last CSR that was created for this order", with CSR referring to a Certificate Signing Request. The way this is worded implies there was a previous CSR but this is a new request and I have nothing previous to fill in here. If I try to leave distguishedName and csr both blank, the call complains. I've tried creating a CSR with openssl and setting the csr field to the value that's created but it doesn't seem to like it. The distinquishedName field I assume is supposed to something like </p>
  
  <pre><code>"CN=mydomain.com,C=US,ST=California,..."
  </code></pre>
  
  <p>but it always complains that whatever I provide is invalid.</p>
  
  <p>I've done some searches and can find no examples of what is needed for this REST call. If anyone can point me to some sample code or additional documentation, I'd appreciate it. Thanks.</p>
  
  <p>Peter</p>