title: Cannot schedule a runbook because of unknown job_schedule_id
body: <p><strong>Im trying to schedule a runbook on Azure programmatically.</strong></p>
  <p>To do this it is necessary to create a runbook, then a schedule and finally to associate the runbook with the schedule. And this can be done in 3 ways (because it's not available on azcli): <strong>API, Powershell or Python-SDK</strong></p>
  <p><strong>Powershell</strong>:</p>
  <p>I did it with powershell in an easy and intuitive way. My runbook is called &quot;my_custom_runbook&quot;, then I create the Schedule and finally I make the association using the name of the runbook and the name of the Schedule.</p>
  <pre><code>    # Create schedule 
      New-AzAutomationSchedule -AutomationAccountName $AutomationAccountName -Name &quot;Daily&quot; -StartTime $CurrentDate -DayInterval 1 -ResourceGroupName $ResourceGroup
      # Link Schedule to Runbook 
      Register-AzAutomationScheduledRunbook -Name &quot;my_custom_runbook&quot; -ResourceGroupName $ResourceGroup -AutomationAccountName $AutomationAccountName -ScheduleName &quot;Daily&quot;
  </code></pre>
  <p><strong>API</strong></p>
  <p>Repeat the same process. First we create the Schedule using this call which has the same parameters:
  <a href="https://docs.microsoft.com/es-es/rest/api/automation/schedule/create-or-update" rel="nofollow noreferrer">https://docs.microsoft.com/es-es/rest/api/automation/schedule/create-or-update</a></p>
  <p><strong>Here comes the problem</strong>. When making the association, <strong>a new parameter is requested: jobScheduleId</strong>. The previous call has only returned a code 200. But if I run get() of the new schedule, the identifier is the name itself, so jobScheduleId is not related to Schedule. Let's continue...</p>
  <p><strong>Python-SDK</strong></p>
  <p>This is the same as in the API. The <strong>job_schedule_id parameter is mandatory and no value is accepted</strong>: None, &quot;&quot; or &quot;random_string&quot;.</p>
  <pre class="lang-py prettyprint-override"><code>CLIENT = AutomationClient(CREDENTIAL, SUB_ID)
      
      def create_schedule():
          params = {'name': 'Daily', 'start_time': datetime.today(), 'frequency': 'Day', 'interval': 1}
          return CLIENT.schedule.create_or_update(RESOURCE_NAME, AUTOMATION_NAME, 'Daily', params)
      
      def assign_runbook_schedule():
          params = {'schedule': {'name':'Daily'}, 'runbook': {'name': 'my_custom_runbook'}}
          job_schedule_id = '???????'
          return CLIENT.job_schedule.create(RESOURCE_NAME, AUTOMATION_NAME, job_schedule_id, params)
  </code></pre>
  <p>Am I missing something or is it really a bug in Azure?</p>
  <p>BTW, I need to do it in API, Python or CLI because I need it to work cross-platform.</p>
  <hr />
  <p><strong>Edit:</strong></p>
  <p>I have discovered that the identifier is created on the fly, it is not an existing value and has this format: xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxx-xxxxxxxxxxxx.</p>
  <p>If the identifier has been created before, it will give an error.
  The problem is that these identifiers cannot be listed or deleted.</p>
  <p>So it's basically a matter of luck.</p>
  <pre class="lang-py prettyprint-override"><code>    CLIENT = AutomationClient(CREDENTIAL, SUB_ID)
      
      def create_schedule():
          params = {'name': 'Daily', 'start_time': datetime.today(), 'frequency': 'Day', 'interval': 1}
          return CLIENT.schedule.create_or_update(RESOURCE_NAME, AUTOMATION_NAME, 'Daily', params)
      
      def assign_runbook_schedule(job_schedule_id):
          params = {'schedule': {'name':'Daily'}, 'runbook': {'name': 'my_custom_runbook'}}
          return CLIENT.job_schedule.create(RESOURCE_NAME, AUTOMATION_NAME, job_schedule_id, params)
  
      def delete_job_schedule(job_schedule_id):
          return automation_client.job_schedule.delete(RESOURCE_NAME, AUTOMATION_NAME, job_schedule_id)
  </code></pre>
  <pre class="lang-sh prettyprint-override"><code>&gt;&gt;&gt; assign_runbook_schedule('99999999-9999-9999-9999-999999999999')
      None #Assignement created
  &gt;&gt;&gt; delete_job_schedule('99999999-9999-9999-9999-999999999999')
      None #Assignement deleted
  &gt;&gt;&gt; assign_runbook_schedule('99999999-9999-9999-9999-999999999999')
          ...
          raise error
      azure.core.exceptions.ResourceExistsError: (Conflict) A jobSchedule with same id already exists.
  &gt;&gt;&gt; assign_runbook_schedule('33333333-3333-3333-3333-333333333333')
      None #Assignement created
  </code></pre>
  <p>When I run <code>delete_job_schedule()</code> I am deleting the runbook-schedule assignment but not the job_schedule object. That's why I can't create it again using the same <code>job_schedule_id</code>.</p>