Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Running Export-M365DSCConfiguration on Azure Automation Runbook does not export files

Open yoinuma opened this issue 4 years ago • 5 comments

I am testing running Export-M365DSCConfiguration on Azure Automation Runbook. However, running Export-M365DSCConfiguration does not output any files.

` $Date = $(Get-Date -f yyyy-MMM-dd-HHMMtt) $applicationId = "" $tenantId = "contoso.onmicrosoft.com" $certificateThumbprint = ""

$tempPath = "$env:TEMP" $initialConfigurationFileName = "InitialM365TenantConfig.ps1" $adminUrl = "https://contoso-admin.sharepoint.com"

write-output "Pulling DSC from Tenant $Date" Export-M365DSCConfiguration -Workloads @("OD", "SPO") -Path $tempPath -ApplicationId $applicationId -TenantId $tenantId -CertificateThumbprint $certificateThumbprint -FileName $initialConfigurationFileName

Get-ChildItem $tempPath ` image

I believe that InitialM365TenantConfig.ps1 should be created under "$env:TEMP", but it is not. Also, the InitialM365TenantConfig.ps1 file is successfully output when this script is run locally, not on Azure Automation. Therefore, I believe that running it on Azure Automation Runbook is related to the event. Does anyone have any ideas for a solution?

yoinuma avatar Nov 01 '22 07:11 yoinuma

Did you use this guide to setup your runbook? https://o365eh.com/2020/10/27/episode-74-using-microsoft-dsc-as-a-runbook-in-azure-automation/

There were some issues related to this guide: https://github.com/microsoft/Microsoft365DSC/issues?q=runbook Please have a look at them as well.

andikrueger avatar Nov 03 '22 09:11 andikrueger

Thanks for the response @andikrueger , Yes, I had this article confirmed. Just to be sure, I ran the M365DSCRunBookInstall part again and then ran Export-M365DSCConfiguration, but still nothing was output. Any other ideas?

yoinuma avatar Nov 08 '22 07:11 yoinuma

Please have a look at this script: https://github.com/microsoft/Microsoft365DSC/issues/2050#issuecomment-1195414547 This could help to setup your environment properly.

andikrueger avatar Nov 08 '22 08:11 andikrueger

@yoinuma did the link that Andi shared above help?

NikCharlebois avatar Nov 18 '22 20:11 NikCharlebois

@andikrueger , @NikCharlebois Thanks for the advice. I have confirmed that we can successfully run Export-M365DSCConfiguration on Azure Automation by running the script https://github.com/microsoft/Microsoft365DSC/issues/2050#issuecomment-1195414547 that you taught me. The issue has been resolved and can be closed. Thanks again!

yoinuma avatar Nov 23 '22 12:11 yoinuma