【问题标题】:Azure Resource Manager: Web App Slots Config: App Service AuthenticationAzure 资源管理器:Web 应用槽配置:应用服务身份验证
【发布时间】:2020-07-01 23:03:11
【问题描述】:

我在将应用服务身份验证应用到我的 Web 应用槽时遇到问题。

我收到的错误如下:

““1”行和“8107”列的类型“Microsoft.WindowsAzure.ResourceStack.Frontdoor.Common.Entities.TemplateGenericProperty`1[System.String]”的模板资源“webapptest1a/authconfig”具有段长度不正确。嵌套资源类型的段数必须与其资源名称相同。根资源类型的段长度必须比其资源名称大 1"

这是我的代码,我认为它非常正确。我发现很难找到 Web App 插槽配置的参考。我有 Microsoft 文档并且我遵循了它,但没有运气。

这是我的代码:

{
        "type": "Microsoft.Web/sites/slots/config",
        "name": "[concat(parameters('webAppName'),'/authconfig')]",
        "apiVersion": "2018-11-01",
        "location": "[resourceGroup().location]",
        "dependsOn": [
            "[parameters('webAppName')]",
            "[concat(parameters('sqlDatabase'), 'constr')]"
        ],
         "properties": {
            "enabled": true,
            "runtimeVersion": "~1",
            "unauthenticatedClientAction": "RedirectToLoginPage",
            "tokenStoreEnabled": true,
            "allowedExternalRedirectUrls": null,
            "defaultProvider": "AzureActiveDirectory",
            "clientId": null,
            "clientSecret": null,
            "clientSecretCertificateThumbprint": null,
            "issuer": null,
            "allowedAudiences": [
                "https://webapptest1a-staging.azurewebsites.net"
            ],
            "additionalLoginParams": null,
            "isAadAutoProvisioned": false,
            "googleClientId": null,
            "googleClientSecret": null,
            "googleOAuthScopes": null,
            "facebookAppId": null,
            "facebookAppSecret": null,
            "facebookOAuthScopes": [
            ""
            ],
            "twitterConsumerKey": null,
            "twitterConsumerSecret": null,
            "microsoftAccountClientId": null,
            "microsoftAccountClientSecret": null,
            "microsoftAccountOAuthScopes": [
            ""
            ]
            }
        },

我真的很脑震荡,我尝试了很多变种,但我没有接近。

我将名称更改为几个不同的变体,然后我得到了不同的错误,但在命名约定方面。

"name": "[concat(parameters('webAppName'), '/appsettings')]",

我还将 Depends on 两次更改为:

"[parameters('webAppName')]",
                "[concat(parameters('sqlDatabase'), 'constr')]"

收件人:

"[concat('Microsoft.Web/sites/', parameters('webAppName'))]",
            "[concat(parameters('sqlDatabase'), 'constr')]"

我真的被困住了!希望得到一些指导。

谢谢

【问题讨论】:

    标签: json azure web-applications azure-resource-manager azure-deployment-slots


    【解决方案1】:

    正如错误所说,“根级别资源的名称必须比资源类型少一个段”。在这里,您传递的资源名称不正确。由于 Type 的段长度为 4,Name 的段长度必须为 3。因此在配置名称中,您还必须传递插槽名称,如下所示(您可以更改根据您的模板的插槽名称和配置名称)

    [concat(parameters('webAppName'), '/staging/web')]

    请查看以下示例以供参考:

    {
        "type": "Microsoft.Web/sites/slots/config",
        "apiVersion": "2018-11-01",
        "name": "[concat(parameters('webAppName'), '/staging/web')]",
        "location": "East US",
        "dependsOn": [
            "[resourceId('Microsoft.Web/sites/slots', parameters('webAppName'), 'staging')]",
            "[resourceId('Microsoft.Web/sites', parameters('webAppName'))]"
        ],
        "properties": {
            "numberOfWorkers": 1,
            "defaultDocuments": [
                "Default.htm",
                "Default.html",
                "Default.asp",
                "index.htm",
                "index.html",
                "iisstart.htm",
                "default.aspx",
                "index.php",
                "hostingstart.html"
            ],
            "netFrameworkVersion": "v4.0",
            "requestTracingEnabled": false,
            "remoteDebuggingEnabled": false,
            "remoteDebuggingVersion": "VS2019",
            "httpLoggingEnabled": false,
            "logsDirectorySizeLimit": 35,
            "detailedErrorLoggingEnabled": false,
            "publishingUsername": "$mytestap345__staging",
            "scmType": "None",
            "use32BitWorkerProcess": true,
            "webSocketsEnabled": false,
            "alwaysOn": false,
            "managedPipelineMode": "Integrated",
            "virtualApplications": [
                {
                    "virtualPath": "/",
                    "physicalPath": "site\\wwwroot",
                    "preloadEnabled": false
                }
            ],
            "loadBalancing": "LeastRequests",
            "experiments": {
                "rampUpRules": []
            },
            "autoHealEnabled": false,
            "localMySqlEnabled": false,
            "ipSecurityRestrictions": [
                {
                    "ipAddress": "Any",
                    "action": "Allow",
                    "priority": 1,
                    "name": "Allow all",
                    "description": "Allow all access"
                }
            ],
            "scmIpSecurityRestrictions": [
                {
                    "ipAddress": "Any",
                    "action": "Allow",
                    "priority": 1,
                    "name": "Allow all",
                    "description": "Allow all access"
                }
            ],
            "scmIpSecurityRestrictionsUseMain": false,
            "http20Enabled": false,
            "minTlsVersion": "1.2",
            "ftpsState": "AllAllowed",
            "reservedInstanceCount": 0
        }
    }
    

    【讨论】:

    • 你好 Jagrati - 我修复了这个错误并收到了一个新错误! “未找到资源组 'MFRS-WEBAPP-AUTH-TEST' 下的资源 'Microsoft.Web/sites/mfrswebapptest1a/slots/slots'。”我知道它在说什么,但我没有看到我在代码中声明的位置......
    • 能否请您添加模板并在另一个问题中提问,以便我查看模板并解决您的问题。谢谢!
    • Jagrati,我添加了一个关于这个问题的新问题 - 如果你愿意,你可以查看:)
    猜你喜欢
    • 1970-01-01
    • 2020-06-10
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-24
    相关资源
    最近更新 更多