簡體   English   中英

在 azure devops 管道版本中部署 webapp w powershell / json 模板 - 錯誤 - 模式對話框無效

[英]deploying webapp in azure devops pipeline release w powershell / json templates - error - modal dialog box is not valid

#Using Azure DevOps 管道版本與一個powershell 腳本和一個json 模板文件和json 參數#file。 對 azure 門戶進行筆記身份驗證需要多因素身份驗證(即我手機上的身份驗證器)

#'ERROR- >>>>> <strong>"Showing a modal dialog box or form when the application is not running in #UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly #style to display a notification from a service application."</strong>
#(Note- Bottom of logs immediately below contains this modal error.)'
    
    
    2020-11-14T20:33:38.7159389Z ##[section]Starting: WebApp_Create01
    2020-11-14T20:33:38.7499602Z ==============================================================================
    2020-11-14T20:33:38.7499865Z Task         : Azure PowerShell
    2020-11-14T20:33:38.7499927Z Description  : Run a PowerShell script within an Azure environment
    2020-11-14T20:33:38.7499981Z Version      : 3.1.28
    2020-11-14T20:33:38.7500050Z Author       : Microsoft Corporation
    2020-11-14T20:33:38.7500132Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-powershell
    2020-11-14T20:33:38.7500215Z ==============================================================================
    2020-11-14T20:33:40.5542183Z ##[command]Import-Module -Name C:\Program Files\WindowsPowerShell\Modules\AzureRM\6.13.1\AzureRM.psd1 -Global
    2020-11-14T20:33:54.9421385Z ##[command]Clear-AzureRmContext -Scope Process
    2020-11-14T20:33:55.3824175Z ##[command]Disable-AzureRmContextAutosave -ErrorAction Stop
    2020-11-14T20:33:56.1766169Z ##[command]Add-AzureRMAccount -ServicePrincipal -Tenant *** -Credential System.Management.Automation.PSCredential -Environment AzXXXXXXXXXXXXXnt @processScope
    2020-11-14T20:33:57.8815316Z ##[command] Select-AzureRMSubscription -SubscriptionId c27XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX2 -TenantId ***
    2020-11-14T20:33:58.5484671Z ##[command]& 'C:\agent\Workfolder_CloudUiPathAgent03\_temp\939d1XXXXXXXXXXXXXXXXXXXXXXXX2127.ps1'
    2020-11-14T20:33:58.7424214Z ##[command]Disconnect-AzureRmAccount -Scope Process -ErrorAction Stop
    2020-11-14T20:33:59.1018440Z ##[command]Clear-AzureRmContext -Scope Process -ErrorAction Stop
    <strong>2020-11-14T20:33:59.7603535Z ##[error]Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.</strong>
    2020-11-14T20:33:59.8133689Z ##[section]Finishing: WebApp_Create01
    <br>
    
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    
    #The immediately below is the ps1 pasted into the section for the "Inline" script.  Pipeline was #created as "Azure Powershell":
    
    
    
    Connect-AzureRmAccount -Environment AzXXXXXXXXXXXXXnt -TenantId '410XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXf1d' -Force
    Select-AzureRmSubscription -Subscription "c271XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX832"
    # Tried both Connect-AzureRmAccount and Login-AzureRmAccount without any success?
    #Login-AzureRmAccount -Environment AzXXXXXXXXXXXXXt | Out-Null
    #Select-AzureRmSubscription -Subscription "c271XXXXXXXXXXXXXXXXXXXXXXXXX832" | Out-Null
    
    <br>
    # Deploy App Service Plan, Web App & Deployment Slots
    $DeploymentParametersBuildVM = @{
        ResourceGroupName = 'DXXXXXXXXXXXXXXXXXXXXXXXXamic'
        TemplateUri       = 'https://dXXXXXXXXXXXXXXXXX.blob.core.XXXXXcloudapi.net/blob-uXXXXXXXXXXXXXXXXXXXXXXXXX7/webappcreate.json'
    TemplateParameterFile = "https://XXXXXXXXXXXXXapi.net/blob-uXXXXXXXXXXXXXXXXXXXXXXXXX7/webappcreate.parameters.json"
        Verbose           = $true
        webAppName        = 'uXXXXXXXXXXXXXXXXXXXXXXXXXXX7'
        hostingPlanName   = 'WebXXXXXXXXXXXXXXXXXXXXXX01' 
        templateSasToken  = 'mtAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXpSTQ=='
        subscriptionId = 'c271XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX832'
        name = 'uXXXXXXXXXXXXXXXXXXXXX7'
        location = 'UXXXXXXXXXXXXXXX'
        serverFarmResourceGroup = 'DXXXXXXXXXXXXXXXXXXXXXXXXamic'
        Tenantid = '410XXXXXXXXXXXXXXXXXXXXXXXXXXXf1d'
        alwaysOn = 'off'    
        sku = 'Free'
        skuCode = 'F1'      
        workerSize = '0'
        workerSizeId = '0'
        numberOfWorkers = '1'
        currentStack = 'dotnet'
        phpVersion = 'OFF'
        appInsightValue = 'uXXXXXXXXXXXXXXXXXXXXXXo7Insight'
        netFrameworkVersion = 'v4.0'
        azureAccountPassword  = '12XXXXXXXXXXXXXXXXXditto'
        accountid = 'a183XXXXXXXXXXXXXXXXXXXXXXXXXXXXX68fa'
        Credential = '12XXXXXXXXXXXXXXXXXditto'
        ServicePrincipal = '_MV_XXXXXXXXXXXXXXXXXXXXXXXXXXXX9~1e'
           
        
    }
    
    
    # DEPLOY
    New-AzureRmResourceGroupDeployment @DeploymentParametersBuildVM
    
    
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    
    #webapp.parameters.json    (this is the azure webapp "parameter" json immediately below): 
    
    
        
    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "subscriptionId": {
                "value": "c271XXXXXXXXXXXXXXXXXXXXXXXXXXXXX832"
            },
            "name": {
                "value": "uXXXXXXXXXXXXXXXXXXX7"
            },
            "location": {
                "value": "UXXXXXXXXXXXXXX"
            },
            "hostingPlanName": {
                "value": "WebXXXXXXXXXXXXXXXXXXX01"
            },
            "serverFarmResourceGroup": {
                "value": "DXXXXXXXXXXXXXXXXXXXic"
            },
            "alwaysOn": {
                "value": "true"
            },
            "sku": {
                "value": "Free"
            },
            "skuCode": {
                "value": "F1"
            },
            "workerSize": {
                "value": "0"
            },
            "workerSizeId": {
                "value": "0"
            },
            "numberOfWorkers": {
                "value": "1"
            },
            "currentStack": {
                "value": "dotnet"
            },
            "phpVersion": {
                "value": "OFF"
            },
            "appInsightValue": {
                "value": "uXXXXXXXXXXXXXXXXXX7Insight"
            },
            "netFrameworkVersion": {
                "value": "v4.0"
            }
        }
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    
    
    #webappacreate.json   (this is the azure webapp "template" json immediately below)
    
    
    
    {
        "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "subscriptionId": {
                "type": "string"
            },
            "name": {
                "type": "string"
            },
            "location": {
                "type": "string"
            },
            "hostingPlanName": {
                "type": "string"
            },
            "serverFarmResourceGroup": {
                "type": "string"
            },
            "alwaysOn": {
                "type": "bool"
            },
            "sku": {
                "type": "string"
            },
            "skuCode": {
                "type": "string"
            },
            "workerSize": {
                "type": "string"
            },
            "workerSizeId": {
                "type": "string"
            },
            "numberOfWorkers": {
                "type": "string"
            },
            "currentStack": {
                "type": "string"
            },
            "phpVersion": {
                "type": "string"
            },
            "appInsightValue": {
                "type": "string"
            },
            "netFrameworkVersion": {
                "type": "string"
            }
        },
        "variables": {
            "appInsightName": "[concat('microsoft.insights/components/',parameters('appInsightValue'))]"
        },
        "resources": [
            {
                "apiVersion": "2018-11-01",
                "name": "[parameters('name')]",
                "type": "Microsoft.Web/sites",
                "location": "[parameters('location')]",
                "tags": {},
                "dependsOn": [
                    "[concat('microsoft.insights/components/',parameters('appInsightValue'))]",
                    "[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
                ],
                "properties": {
                    "name": "[parameters('name')]",
                    "siteConfig": {
                        "appSettings": [
                            {
                                "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                                "value": "[reference(variables('appInsightName'), '2015-05-01').InstrumentationKey]"
                            },
                            {
                                "name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
                                "value": "[reference(variables('appInsightName'), '2015-05-01').ConnectionString]"
                            },
                            {
                                "name": "ApplicationInsightsAgent_EXTENSION_VERSION",
                                "value": "~2"
                            },
                            {
                                "name": "XDT_MicrosoftApplicationInsights_Mode",
                                "value": "default"
                            }
                        ],
                        "metadata": [
                            {
                                "name": "CURRENT_STACK",
                                "value": "[parameters('currentStack')]"
                            }
                        ],
                        "phpVersion": "[parameters('phpVersion')]",
                        "netFrameworkVersion": "[parameters('netFrameworkVersion')]",
                        "alwaysOn": "[parameters('alwaysOn')]"
                    },
                    "serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
                    "clientAffinityEnabled": true
                }
            },
            {
                "apiVersion": "2018-11-01",
                "name": "[parameters('hostingPlanName')]",
                "type": "Microsoft.Web/serverfarms",
                "location": "[parameters('location')]",
                "kind": "",
                "tags": {},
                "dependsOn": [],
                "properties": {
                    "name": "[parameters('hostingPlanName')]",
                    "workerSize": "[parameters('workerSize')]",
                    "workerSizeId": "[parameters('workerSizeId')]",
                    "numberOfWorkers": "[parameters('numberOfWorkers')]"
                },
                "sku": {
                    "Tier": "[parameters('sku')]",
                    "Name": "[parameters('skuCode')]"
                }
            },
            {
                "apiVersion": "2015-05-01",
                "name": "[parameters('appInsightValue')]",
                "type": "microsoft.insights/components",
                "location": "[parameters('location')]",
                "tags": {},
                "properties": {
                    "ApplicationId": "[parameters('name')]",
                    "Request_Source": "IbizaWebAppExtensionCreate"
                }
            }
        ]
    }

根據錯誤消息,您似乎需要將MessageBox.Show的選項設置為ServiceNotificationDefaultDesktopOnly 您可以嘗試此票中提供的解決方法:添加MessageBoxOptions.ServiceNotification

MessageBox.Show(msg, "Print Error", System.Windows.Forms.MessageBoxButtons.YesNo, 
   System.Windows.Forms.MessageBoxIcon.Error,     
   System.Windows.Forms.MessageBoxDefaultButton.Button1, 
   System.Windows.Forms.MessageBoxOptions.ServiceNotification); 

但是,MessageBox 用於 Windows(而不是 Web)應用程序中。 它會嘗試在服務器上打開一個消息框。 這是一張你可以參考的

發現 azure devops 管道不需要身份驗證,因此不需要登錄或連接。 這擺脫了彈出窗口(模態錯誤)。

接下來,我與 azure devops 人員核對,他說不要在管道中使用 powershell。

他為管道發布推薦了“Azure Resource Group Deployment”選項。 這不需要任何啟動腳本,只需要一個 json 模板和一個 json 參數。

謝謝你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM