Work 365 supports Azure billing by importing Microsoft reported Azure consumption into a Storage mechanism. If you are using Classing Azure billing (using Dynamics as a storage) this article applies to you. 

NOTE: Classic Azure Where the data is stored in CRM is deprecated and will out of support shortly. 

There may be times when attempting to delete an Azure invoice in Work 365 get’s stuck due to a Dynamics 365 time out error appearing like this.

or an Offline error message like this

When an Azure invoice is deleted all the Usage Summary records, and all usage detail records for legacy Azure subscriptions, linked to the invoice have to be unlinked and updated as “Active” or billable again. Dynamics has to complete this action within a 2 minute time period or it errors out. Essentially, if there are too many usage summary records which have to be updated but cannot be processed in the 2 minute time period an invoice would fail to delete. Subsequently, any additional attempts at deleting an Azure invoice will results in the same error.
Here are the steps to take to resolve this issue.

  1. Create an advanced find view looking for Usage Summary.
    1. Add Status Reason as an additional column to the view
    2. Save the view
  2. Go to the invoice which needs to be deleted
    1. Within the invoice go to Related > Usage Summary
    2. Change the usage summary view drop down (on the left above the usage data) to the view which was saved from the first step
    3. On the right side hit the three dots above the Usage Summary table
      1. Select Export to Excel
      2. Then select Export usage Summary in Excel online
      3. Update the Status Reason of the records to Active and delete the invoice lines from the invoice column.
        1. Updating the status reason from Archived to Active will enable this usage data to be invoice again.
        2. Deleting the invoice from the invoice column will remove the link between the usage summary records and the invoice itself.
      4. Hit Save for CRM to automatically update the records. Depending on the number of records being updated, this could take several minutes.
  3. The invoice should show no usage summary records after they have been updated.
  4. Complete the same steps 1-3 for any usage detail records linked to the invoice (applicable for legacy Azure subscriptions).
  5. Then in CRM go to Advanced Settings > System Jobs
    1. Under System Jobs change the view to Cascade Operations
      1. Select the Cascade Delete job for the item in waiting status. Also make sure the System Job Name selected has Invoice in the name.
      2. Hit the drop down for More Actions > Select Cancel
  6. Go back to the invoice record which needs to be deleted. Hit delete.