Skip to content

xWebAppPool and xWebApplication cannot delete entities in use and do nothing #623

@i2um1

Description

@i2um1

Problem description

Hi,

I have a self contained ASP.NET Core web application that I host on IIS. The app pool is configured to always running. So, I want to delete the web application using xWebAppPool and xWebApplication. In case, if a web application was in use a few seconds ago, xWebAppPool and xWebApplication does nothing.

Verbose logs

12:25:55       | Instance i-xxxx: Access is denied. The related file/directory is: C:\Site\MySite. The
12:25:55       | related file/directory is:  C:\Site\MySite.  The related ResourceID is [File]DeleteFolder.     +
12:25:55       | CategoryInfo          : PermissionDenied: (:) [], CimException     + FullyQualifiedErrorId : Windows System
12:25:55       | Error 5     + PSComputerName        : localhost   The SendConfigurationApply function did not succeed.     +
12:25:55       | CategoryInfo          : PermissionDenied: (root/Microsoft/...gurationManager:String) [], CimException     +
12:25:55       | FullyQualifiedErrorId : MI RESULT 2     + PSComputerName        : localhost

DSC configuration

Configuration DeleteWebApplication {
    Import-DscResource -Module PSDesiredStateConfiguration
    Import-DscResource -ModuleName xWebAdministration

    xWebApplication DeleteWebApplication {
        Name = $applicationName
        Ensure = 'Absent'
        Website = $webSiteName
        WebAppPool = $applicationName
        PhysicalPath = $applicationPath
    }

    xWebAppPool DeleteAppPool {
        Name = $applicationName
        Ensure = 'Absent'
    }

    File DeleteFolder {
        DestinationPath = $applicationPath
        Ensure = 'Absent'
        Type = 'Directory'
        Recurse = $true
        Force = $true
    }

}

DeleteWebApplication
Start-DscConfiguration -Path .\DeleteWebApplication\ -Wait -Force

Suggested solution

I think the easiest solution is to have any retry strategy because, usually, the second try deletes a web application and an app pool as expected.

Operating system the target node is running

OsName               : Microsoft Windows Server 2019 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 1809
WindowsBuildLabEx    : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value
----                           -----
PSVersion                      5.1.17763.134
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.134
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

WebAdministrationDsc version

Name               Version Path
----               ------- ----
xWebAdministration 3.3.0   C:\Program Files\WindowsPowerShell\Modules\xWebAdministration\3.3.0\xWebAdministration.psd1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions