Azure / Azure/azure-powershell

New-AzApiManagementBackend 4.0.5 fails with "'url' should not be empty"

Open
#26,837 8 comments 0 reactions 0 assignees View on GitHub
act-observability-squad API Management bug customer-reported
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

When using Az.ApiManagement 4.0.5, `New-AzApiManagementBackend` command fails even when parameters are provided.
```
New-AzApiManagementBackend `
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Error Code: ValidationError Error Message: One or more fields contain
| incorrect values: Request Id: 2dd68334-2530-4284-b326-48e03b5789b7 Error
| Details: [Code= ValidationError, Message= 'url' should not be empty.,
| Target= url] [Code= ValidationError, Message= 'protocol' should not be
| empty., Target= protocol]
```

### Issue script & Debug output

```PowerShell
Script:

$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName $ApimResourceGroup -ServiceName $ApiMgmtName
$BackendCredential = New-AzApiManagementBackendCredential -Header @{"x-functions-key" = @("{{valval}}") }
New-AzApiManagementBackend `
-Context $ApiMgmtContext `
-BackendId $BackendName `
-Protocol http `
-Url "https://my-domain.com/api" `
-Credential $BackendCredential

Logs:

DEBUG: Initializing ConditionalAssemblyContext. PSEdition is [Core]. PSVersion is [7.4.6].
DEBUG: Initializing ConditionalAssemblyProvider. AssemblyRootPath is [/home/tpawel/.local/share/powershell/Modules/Az.Accounts/4.0.0/StartupScripts/../lib].
DEBUG: Registering Az shared AssemblyLoadContext.
DEBUG: AssemblyLoadContext registered.
DEBUG: Initializing PSStyle.
DEBUG: Got version 0 of Az
DEBUG: Got version 0 of Az.Accounts
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - NewAzureApiManagementContext begin processing with ParameterSet 'ContextParameterSet'.
DEBUG: 5:07:11 PM - using account id '[REDACTED]'...
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.ApiManagement:4.0.5; CommandName: New-AzApiManagementContext; PSVersion: 7.4.6; IsSuccess: True; Duration: 00:00:00.0195837; SanitizeDuration: 00:00:00.0006008
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - NewAzureApiManagementContext end processing.
Importing api...
Creating backend
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - NewAzureApiManagementBackendCredential begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 5:07:11 PM - using account id '[REDACTED]'...
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.ApiManagement:4.0.5; CommandName: New-AzApiManagementBackendCredential; PSVersion: 7.4.6; IsSuccess: True; Duration: 00:00:00.0011815; SanitizeDuration: 00:00:00.0002764
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - NewAzureApiManagementBackendCredential end processing.
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplaySecretsWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:11 PM - NewAzureApiManagementBackend begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 5:07:11 PM - using account id '[REDACTED]'...
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: '[REDACTED]', environment: 'AzureCloud', tenant: '[REDACTED]'
DEBUG: 5:07:11 PM - [ConfigManager] Got nothing from [DisableInstanceDiscovery], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 5:07:11 PM - [ConfigManager] Got [False] from [EnableLoginByWam], Module = [], Cmdlet = [].
DEBUG: 5:07:11 PM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'[REDACTED]', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'[REDACTED]'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 11f635c7-a96d-423c-95db-8cbcdf3db2e5] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 11f635c7-a96d-423c-95db-8cbcdf3db2e5] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 11f635c7-a96d-423c-95db-8cbcdf3db2e5] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 11f635c7-a96d-423c-95db-8cbcdf3db2e5] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 11f635c7-a96d-423c-95db-8cbcdf3db2e5] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z] Found 1 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z] Returning 1 accounts
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] MSAL MSAL.CoreCLR with assembly version '4.65.0.0'. CorrelationId(1005b4fe-f3c3-4f6d-ba13-af98c17946cb)
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] LoginHint provided: False
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] Account provided: True
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] ForceRefresh: False
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:

DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] === Token Acquisition (SilentRequest) started:
Scopes: https://management.core.windows.net//.default
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] Access token is not expired. Returning the found cache entry. [Current time (12/04/2024 17:07:12) - Expiration Time (12/04/2024 18:25:45 +00:00) - Extended Expiration Time (12/04/2024 18:25:45 +00:00)]
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] Returning access token found in cache. RefreshOn exists ? False
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb]
=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.65.0.0 MSAL.CoreCLR .NET 8.0.10 Linux [2024-12-04 17:07:12Z - 1005b4fe-f3c3-4f6d-ba13-af98c17946cb] AT expiration time: 12/4/2024 6:25:45 PM +00:00, scopes: https://management.core.windows.net//.default https://management.core.windows.net//user_impersonation. source: Cache
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2024-12-04T18:25:45.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: [REDACTED], UserId: '[REDACTED]'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PUT

Absolute Uri: [REDACTED]

Headers:
Accept-Language : en-US
x-ms-client-request-id : 9a2e8cfe-e4da-445f-a081-2a9d8c5bc4a2

Body:
{
"properties": {
"credentials": {
"header": {
"x-functions-key": [
"{{valval}}"
]
}
}
}
}

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
BadRequest

Headers:
Cache-Control : no-cache
Pragma : no-cache
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
x-ms-request-id : ee31d0aa-d430-4fdc-a4ea-9955a1a71be7
x-ms-ratelimit-remaining-subscription-writes: 199
x-ms-ratelimit-remaining-subscription-global-writes: 2999
x-ms-correlation-request-id : ee31d0aa-d430-4fdc-a4ea-9955a1a71be7
x-ms-routing-request-id : NORTHEUROPE:20241204T170712Z:ee31d0aa-d430-4fdc-a4ea-9955a1a71be7
X-Cache : CONFIG_NOCACHE
X-MSEdge-Ref : Ref A: 6255015791FA43A7B8DF15942AB31301 Ref B: AMS231032609033 Ref C: 2024-12-04T17:07:12Z
Date : Wed, 04 Dec 2024 17:07:11 GMT

Body:
{
"error": {
"code": "ValidationError",
"message": "One or more fields contain incorrect values:",
"details": [
{
"code": "ValidationError",
"target": "url",
"message": "'url' should not be empty."
},
{
"code": "ValidationError",
"target": "protocol",
"message": "'protocol' should not be empty."
}
]
}
}

DEBUG: 5:07:12 PM - [ConfigManager] Got nothing from [EnableErrorRecordsPersistence], Module = [], Cmdlet = []. Returning default value [False].
New-AzApiManagementBackend: deploy.ps1:104:5
Line |
104 | New-AzApiManagementBackend `
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Error Code: ValidationError Error Message: One or more
| fields contain incorrect values: Request Id:
| ee31d0aa-d430-4fdc-a4ea-9955a1a71be7 Error Details: [Code=
| ValidationError, Message= 'url' should not be empty.,
| Target= url] [Code= ValidationError, Message= 'protocol'
| should not be empty., Target= protocol]
DEBUG: 5:07:12 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:12 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:12 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.ApiManagement:4.0.5; CommandName: New-AzApiManagementBackend; PSVersion: 7.4.6; IsSuccess: False; Duration: 00:00:01.2171898; SanitizeDuration: 00:00:00; Exception:
Error Code: ValidationError
Error Message: One or more fields contain incorrect values:
Request Id: ee31d0aa-d430-4fdc-a4ea-9955a1a71be7
Error Details:
[Code= ValidationError, Message= 'url' should not be empty., Target= url]
[Code= ValidationError, Message= 'protocol' should not be empty., Target= protocol]
;
DEBUG: 5:07:12 PM - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 5:07:12 PM - NewAzureApiManagementBackend end processing.
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Ubuntu 24.04.1 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```

### Module versions

```PowerShell
Version Name Repository
------- ---- ----------
4.1.1 Az.Functions PSGallery
4.0.5 Az.ApiManagement PSGallery
4.0.0 Az.Accounts PSGallery
```

### Error output

```PowerShell

```

Contributor guide

Open the contributing guide

Research direction

Start from the New-AzApiManagementBackend command and its parameter handling, then compare the supplied -Protocol and -Url values with the HTTP request body shown in the issue. Reproduce the failure with the provided PowerShell script; done means the request preserves both values and the backend is created successfully without validation errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.