add_azure_account_and_set_role_assignment_1.py 861 B

12345678910111213141516
  1. def create_azure_account(env, CloudCheckrApiKey, account_name, AzureDirectoryId, AzureCloudCheckrApplicationId,
  2. AzureCloudCheckrApplicationSecret, AzureSubscriptionId):
  3. """
  4. Creates an Azure Account in CloudCheckr. It will populate it with azure subscription credentials that were provided.
  5. """
  6. api_url = env + "/api/account.json/add_azure_inventory_account"
  7. add_azure_account_info = json.dumps(
  8. {"account_name": account_name, "azure_ad_id": AzureDirectoryId, "azure_app_id": AzureCloudCheckrApplicationId,
  9. "azure_api_access_key": AzureCloudCheckrApplicationSecret, "azure_subscription_id": AzureSubscriptionId})
  10. r7 = requests.post(api_url, headers={"Content-Type": "application/json", "access_key": CloudCheckrApiKey},
  11. data=add_azure_account_info)
  12. print(r7.json())