Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXORemoteDomain should implement a wait/retry mecanism between the New-RemoteDomain and Set-RemoteDomain #3628

Closed
levesquesamuel opened this issue Aug 31, 2023 · 0 comments · Fixed by #3631 or #3651

Comments

@levesquesamuel
Copy link
Contributor

Description of the issue

function Set-TargetResource
[...]

CASE: Remote Domain doesn't exist but should;

if ($Ensure -eq 'Present' -and $currentRemoteDomainConfig.Ensure -eq 'Absent')
{
    Write-Verbose -Message "Remote Domain '$($Name)' does not exist but it should. Create and configure it."
    # Create remote domain
    if ([System.String]::IsNullOrEmpty($Name))
    {
        $Name = $Identity
    }
    New-RemoteDomain -Name $Name -DomainName $DomainName**

There should be a wait/retry mecanism here**

    # Configure new remote domain
    $RemoteDomainParams.Remove('DomainName') | Out-Null
    Set-RemoteDomain @RemoteDomainParams**
}

Something similar exist in this ressource:

$currentAADApp = New-MgApplication @currentParameters
Write-Verbose -Message "Azure AD Application {$DisplayName} was successfully created"
$needToUpdatePermissions = $true

    $tries = 1
    $appEntity = $null
    do
    {
        Write-Verbose -Message 'Waiting for 10 seconds'
        Start-Sleep -Seconds 10
        $appEntity = Get-MgApplication -ApplicationId $currentAADApp.AppId -ErrorAction SilentlyContinue
        $tries++
    } until ($null -eq $appEntity -or $tries -le 12)

Microsoft 365 DSC Version

1.23.628.1

Which workloads are affected

Exchange Online

The DSC configuration

Generated with Microsoft365DSC version 1.23.628.1

For additional information on how to use Microsoft365DSC, please visit https://aka.ms/M365DSC

param (
)

Configuration M365TenantConfig
{
param (
)

$OrganizationName = $ConfigurationData.NonNodeData.OrganizationName

Import-DscResource -ModuleName 'Microsoft365DSC' -ModuleVersion '1.23.628.1'

Node localhost
{
    EXORemoteDomain "EXORemoteDomain-Default"
    {
        AllowedOOFType                       = "External";
        ApplicationId                        = $ConfigurationData.NonNodeData.ApplicationId;
        AutoForwardEnabled                   = $True;
        AutoReplyEnabled                     = $True;
        ByteEncoderTypeFor7BitCharsets       = "Undefined";
        CertificateThumbprint                = $ConfigurationData.NonNodeData.CertificateThumbprint;
        CharacterSet                         = "iso-8859-1";
        ContentType                          = "MimeHtmlText";
        DeliveryReportEnabled                = $True;
        DisplaySenderName                    = $True;
        DomainName                           = "*";
        Ensure                               = "Present";
        Identity                             = "Default";
        IsInternal                           = $False;
        LineWrapSize                         = "Unlimited";
        MeetingForwardNotificationEnabled    = $False;
        Name                                 = "Default";
        NDREnabled                           = $True;
        NonMimeCharacterSet                  = "iso-8859-1";
        PreferredInternetCodePageForShiftJis = "Undefined";
        TargetDeliveryDomain                 = $False;
        TenantId                             = $OrganizationName;
        TrustedMailInboundEnabled            = $False;
        TrustedMailOutboundEnabled           = $False;
        UseSimpleDisplayName                 = $False;
    }
    EXORemoteDomain "EXORemoteDomain-Contosoaaaa"
    {
        AllowedOOFType                       = "External";
        ApplicationId                        = $ConfigurationData.NonNodeData.ApplicationId;
        AutoForwardEnabled                   = $True;
        AutoReplyEnabled                     = $True;
        ByteEncoderTypeFor7BitCharsets       = "Undefined";
        CertificateThumbprint                = $ConfigurationData.NonNodeData.CertificateThumbprint;
        CharacterSet                         = "";
        ContentType                          = "MimeHtmlText";
        DeliveryReportEnabled                = $True;
        DisplaySenderName                    = $True;
        DomainName                           = "*.aaaacontoso.com";
        Ensure                               = "Present";
        Identity                             = "Contosoaaaa";
        IsInternal                           = $False;
        LineWrapSize                         = "Unlimited";
        MeetingForwardNotificationEnabled    = $False;
        Name                                 = "Contosoaaaa";
        NDREnabled                           = $True;
        NonMimeCharacterSet                  = "";
        PreferredInternetCodePageForShiftJis = "Undefined";
        TargetDeliveryDomain                 = $False;
        TenantId                             = $OrganizationName;
        TrustedMailInboundEnabled            = $False;
        TrustedMailOutboundEnabled           = $False;
        UseSimpleDisplayName                 = $False;
    }
    EXORemoteDomain "EXORemoteDomain-Contosobbbb"
    {
        AllowedOOFType                       = "External";
        ApplicationId                        = $ConfigurationData.NonNodeData.ApplicationId;
        AutoForwardEnabled                   = $True;
        AutoReplyEnabled                     = $True;
        ByteEncoderTypeFor7BitCharsets       = "Undefined";
        CertificateThumbprint                = $ConfigurationData.NonNodeData.CertificateThumbprint;
        CharacterSet                         = "";
        ContentType                          = "MimeHtmlText";
        DeliveryReportEnabled                = $True;
        DisplaySenderName                    = $True;
        DomainName                           = "*.bbbbcontoso.com";
        Ensure                               = "Present";
        Identity                             = "Contosobbbb";
        IsInternal                           = $False;
        LineWrapSize                         = "Unlimited";
        MeetingForwardNotificationEnabled    = $False;
        Name                                 = "Contosobbbb";
        NDREnabled                           = $True;
        NonMimeCharacterSet                  = "";
        PreferredInternetCodePageForShiftJis = "Undefined";
        TargetDeliveryDomain                 = $False;
        TenantId                             = $OrganizationName;
        TrustedMailInboundEnabled            = $False;
        TrustedMailOutboundEnabled           = $False;
        UseSimpleDisplayName                 = $False;
    }
    EXORemoteDomain "EXORemoteDomain-Contosozzz"
    {
        AllowedOOFType                       = "None";
        ApplicationId                        = $ConfigurationData.NonNodeData.ApplicationId;
        AutoForwardEnabled                   = $True;
        AutoReplyEnabled                     = $True;
        ByteEncoderTypeFor7BitCharsets       = "Undefined";
        CertificateThumbprint                = $ConfigurationData.NonNodeData.CertificateThumbprint;
        CharacterSet                         = "";
        ContentType                          = "MimeHtmlText";
        DeliveryReportEnabled                = $False;
        DisplaySenderName                    = $True;
        DomainName                           = "*.contosozzz.com";
        Ensure                               = "Present";
        Identity                             = "Contosozzz";
        IsInternal                           = $False;
        LineWrapSize                         = "Unlimited";
        MeetingForwardNotificationEnabled    = $False;
        Name                                 = "Contosozzz";
        NDREnabled                           = $True;
        NonMimeCharacterSet                  = "";
        PreferredInternetCodePageForShiftJis = "Undefined";
        TargetDeliveryDomain                 = $False;
        TenantId                             = $OrganizationName;
        TNEFEnabled                          = $True;
        TrustedMailInboundEnabled            = $False;
        TrustedMailOutboundEnabled           = $False;
        UseSimpleDisplayName                 = $False;
    }
    EXORemoteDomain "EXORemoteDomain-Contoso"
    {
        AllowedOOFType                       = "External";
        ApplicationId                        = $ConfigurationData.NonNodeData.ApplicationId;
        AutoForwardEnabled                   = $True;
        AutoReplyEnabled                     = $True;
        ByteEncoderTypeFor7BitCharsets       = "Undefined";
        CertificateThumbprint                = $ConfigurationData.NonNodeData.CertificateThumbprint;
        CharacterSet                         = "";
        ContentType                          = "MimeHtmlText";
        DeliveryReportEnabled                = $True;
        DisplaySenderName                    = $True;
        DomainName                           = "*.contoso.com";
        Ensure                               = "Present";
        Identity                             = "Contoso";
        IsInternal                           = $False;
        LineWrapSize                         = "Unlimited";
        MeetingForwardNotificationEnabled    = $False;
        Name                                 = "Contoso";
        NDREnabled                           = $True;
        NonMimeCharacterSet                  = "";
        PreferredInternetCodePageForShiftJis = "Undefined";
        TargetDeliveryDomain                 = $False;
        TenantId                             = $OrganizationName;
        TrustedMailInboundEnabled            = $False;
        TrustedMailOutboundEnabled           = $False;
        UseSimpleDisplayName                 = $False;
    }
}

}

M365TenantConfig -ConfigurationData .\ConfigurationData.psd1

Verbose logs showing the problem

This has happened once but when we ran it again we could see the RemoteDomain existed.

image

Environment Information + PowerShell Version

OsName               : Microsoft Windows 11 Pro
OsOperatingSystemSKU : 48
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage           : en-US
OsMuiLanguages       : {en-US, en-GB}

Name                           Value
----                           -----
PSVersion                      5.1.22621.1778
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.1778
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
levesquesamuel added a commit to levesquesamuel/Microsoft365DSC that referenced this issue Aug 31, 2023
NikCharlebois added a commit that referenced this issue Aug 31, 2023
EXORemoteDomain - Implement a wait/retry mecanism - Fixes #3628
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant