Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.25k stars 3.85k forks source link

Unable to retrieve "Microsoft.Web/hostingEnvironments/capacities" #7166

Open lwajswaj opened 6 years ago

lwajswaj commented 6 years ago

Description

No Provider for "Microsoft.Web/hostingEnvironments/capacities"; unable to retrieve ASE ILB Private IP. If I include -ApiVersion, the body contains the information but it isn't parsed; otherwise, the body is empty.

Script/Steps for Reproduction

$vip = Get-AzureRmResource -ResourceGroupName "ResourceGroupName" -ResourceType Microsoft.Web/hostingEnvironments/capacities -ResourceName ASEName/virtualip

Module Version

PS C:\Users\Leandro.Wajswajn> Get-Module AzureRM -ListAvailable

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     6.7.0      AzureRM
Script     6.6.0      AzureRM
Script     6.4.0      AzureRM
Script     5.7.0      AzureRM

Environment Data

PS C:\Users\Leandro.Wajswajn> $PSVersionTable

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

Debug Output

PS C:\Users\Leandro.Wajswajn> $vip = Get-AzureRmResource -ResourceGroupName ResourceGroupName -ResourceType Microsoft
.Web/hostingEnvironments/capacities -ResourceName ASEName/virtualip -debug -ApiVersion 2018-02-01
DEBUG: 20:39:31 - GetAzureResourceCmdlet begin processing with ParameterSet 'ByTagNameValueParameterSet'.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): A
DEBUG: 20:39:32 - using account id 'xxxxxxx@xxxx.xxxx'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'xxxxxxx@xxxx.xxxx', environment: 'AzureCloud',
tenant: 'TenantId'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:32:  - TokenCache: Serializing token cache with 13 items.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:32:  - TokenCache: Serializing token cache with 13 items.
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain:
'TenantId', Endpoint: 'https://login.microsoftonline.com/', ClientId:
'1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri:
'https://management.core.windows.net/', ValidateAuthrity: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority
'https://login.microsoftonline.com/TenantId/', CorrelationId:
'00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain:
'TenantId', AdEndpoint: 'https://login.microsoftonline.com/', ClientId:
'1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:32: cdb85581-cd0f-4189-b421-3c26a984dd51 - AcquireTokenHandlerBase: === Token Acquisition
started:
 Authority: https://login.microsoftonline.com/TenantId/
 Resource: https://management.core.windows.net/
 ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (13 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:32:  - TokenCache: Deserialized 13 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/07/2018 23:39:32: cdb85581-cd0f-4189-b421-3c26a984dd51 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:32: cdb85581-cd0f-4189-b421-3c26a984dd51 - TokenCache: An item matching the requested resource
was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/07/2018 23:39:32: cdb85581-cd0f-4189-b421-3c26a984dd51 - TokenCache: 43.3708035866667 minutes left until
token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:32: cdb85581-cd0f-4189-b421-3c26a984dd51 - TokenCache: A matching item (access token or refresh
 token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:32: cdb85581-cd0f-4189-b421-3c26a984dd51 - AcquireTokenHandlerBase: === Token Acquisition
finished successfully. An access token was retuned:
 Access Token Hash: BTZHOZsVU/W7kTfDXn+M9mUfYi9qwCGdBbS9imHwUtY=
 Refresh Token Hash: BERskTPKlhSIsRwF2N9RfI0fGwcvXCREjnlAsdTEUOI=
 Expiration Time: 09/08/2018 00:22:54 +00:00
 User Hash: lhIWWGoBn7lZutEMIBRS+ymGypeM/6gDwj8R1h3EXXQ=

DEBUG: [Common.Authentication]: Received token with LoginType 'LiveId', Tenant: 'TenantId',
 UserId: 'xxxxxxx@xxxx.xxxx'
DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '09/08/2018 00:22:54 +00:00',
MultipleResource? 'True', Tenant: 'TenantId', UserId: 'xxxxxxx@xxxx.xxxx'
DEBUG: [Common.Authentication]: User info for token DisplayId: 'xxxxxxx@xxxx.xxxx', Name: Leandro Wajswajn Pereyra
AR014251056, IdProvider: 'https://sts.windows.net/TenantId/', Uid:
'012b66f7-bb7f-46f4-906b-9c0b28c9288c'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '09/08/2018 00:22:54 +00:00' Comparing to
'09/07/2018 23:39:32 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:43:22.2482152'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/SubscriptionId/resourceGroups/ResourceGroupName/pro
viders/Microsoft.Web/hostingEnvironments/ASEName/capacities/virtualip?api-version=2018-02-01

Headers:
User-Agent                    : AzurePowershell/v6.7.0,PSVersion/v5.1.16299.611
ParameterSetName              : ByTagNameValueParameterSet
CommandName                   : Get-AzureRmResource

Body:

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

Status Code:
OK

Headers:
Pragma                        : no-cache
Strict-Transport-Security     : max-age=31536000; includeSubDomains
x-ms-request-id               : 61e66cbf-aaa4-4516-a5ca-6f9097202d29
x-ms-ratelimit-remaining-subscription-reads: 11989
x-ms-correlation-request-id   : 0c979386-8b0c-4bc7-9ca6-c6231a9e8839
x-ms-routing-request-id       : BRAZILSOUTH:20180907T233943Z:0c979386-8b0c-4bc7-9ca6-c6231a9e8839
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Fri, 07 Sep 2018 23:39:43 GMT
Server                        : Microsoft-IIS/10.0
X-AspNet-Version              : 4.0.30319
X-Powered-By                  : ASP.NET

Body:
{
  "serviceIpAddress": "157.55.143.197",
  "internalIpAddress": "10.47.1.139",
  "outboundIpAddresses": [
    "157.55.143.197"
  ],
  "vipMappings": []
}

DEBUG: 20:39:43 - GetAzureResourceCmdlet end processing.
DEBUG: 20:39:43 - GetAzureResourceCmdlet end processing.
PS C:\Users\Leandro.Wajswajn> $vip

PS C:\Users\Leandro.Wajswajn> $vip = Get-AzureRmResource -ResourceGroupName ResourceGroupName -ResourceType Microsoft
.Web/hostingEnvironments/capacities -ResourceName ASEName/virtualip -debug
DEBUG: 20:39:54 - GetAzureResourceCmdlet begin processing with ParameterSet 'ByTagNameValueParameterSet'.

Confirm
Continue with this operation?
[Y] Yes  [A] Yes to All  [H] Halt Command  [S] Suspend  [?] Help (default is "Y"): A
DEBUG: 20:39:55 - using account id 'xxxxxxx@xxxx.xxxx'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'xxxxxxx@xxxx.xxxx', environment: 'AzureCloud',
tenant: 'TenantId'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55: 361f5a03-e5c9-4dc6-afe1-5abbbbe913bf - AcquireTokenHandlerBase: === Token Acquisition
started:
 Authority: https://login.microsoftonline.com/TenantId/
 Resource: https://management.core.windows.net/
 ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (13 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55:  - TokenCache: Deserialized 13 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/07/2018 23:39:55: 361f5a03-e5c9-4dc6-afe1-5abbbbe913bf - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55: 361f5a03-e5c9-4dc6-afe1-5abbbbe913bf - TokenCache: An item matching the requested resource
was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/07/2018 23:39:55: 361f5a03-e5c9-4dc6-afe1-5abbbbe913bf - TokenCache: 42.981775245 minutes left until token in
 cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55: 361f5a03-e5c9-4dc6-afe1-5abbbbe913bf - TokenCache: A matching item (access token or refresh
 token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55: 361f5a03-e5c9-4dc6-afe1-5abbbbe913bf - AcquireTokenHandlerBase: === Token Acquisition
finished successfully. An access token was retuned:
 Access Token Hash: BTZHOZsVU/W7kTfDXn+M9mUfYi9qwCGdBbS9imHwUtY=
 Refresh Token Hash: BERskTPKlhSIsRwF2N9RfI0fGwcvXCREjnlAsdTEUOI=
 Expiration Time: 09/08/2018 00:22:54 +00:00
 User Hash: lhIWWGoBn7lZutEMIBRS+ymGypeM/6gDwj8R1h3EXXQ=

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55: 1733c350-3899-4e56-a0ad-7a7c06c2e0be - AcquireTokenHandlerBase: === Token Acquisition
started:
 Authority: https://login.microsoftonline.com/TenantId/
 Resource: https://management.core.windows.net/
 ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (13 items)
 Authentication Target: User

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55:  - TokenCache: Deserialized 13 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/07/2018 23:39:55: 1733c350-3899-4e56-a0ad-7a7c06c2e0be - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55: 1733c350-3899-4e56-a0ad-7a7c06c2e0be - TokenCache: An item matching the requested resource
was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 09/07/2018 23:39:55: 1733c350-3899-4e56-a0ad-7a7c06c2e0be - TokenCache: 42.98073354 minutes left until token in
cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55: 1733c350-3899-4e56-a0ad-7a7c06c2e0be - TokenCache: A matching item (access token or refresh
 token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 09/07/2018 23:39:55: 1733c350-3899-4e56-a0ad-7a7c06c2e0be - AcquireTokenHandlerBase: === Token Acquisition
finished successfully. An access token was retuned:
 Access Token Hash: BTZHOZsVU/W7kTfDXn+M9mUfYi9qwCGdBbS9imHwUtY=
 Refresh Token Hash: BERskTPKlhSIsRwF2N9RfI0fGwcvXCREjnlAsdTEUOI=
 Expiration Time: 09/08/2018 00:22:54 +00:00
 User Hash: lhIWWGoBn7lZutEMIBRS+ymGypeM/6gDwj8R1h3EXXQ=

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/SubscriptionId/resourceGroups/ResourceGroupName/res
ources?$filter=resourceType EQ 'Microsoft.Web/hostingEnvironments/capacities'&api-version=2018-05-01

Headers:
x-ms-client-request-id        : ec1d5d8c-3f41-4522-ab83-16ff7b2350ba
accept-language               : en-US

Body:

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

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11995
x-ms-request-id               : 019e7278-e524-4fec-9163-1d5925ddd775
x-ms-correlation-request-id   : 019e7278-e524-4fec-9163-1d5925ddd775
x-ms-routing-request-id       : BRAZILSOUTH:20180907T234000Z:019e7278-e524-4fec-9163-1d5925ddd775
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Cache-Control                 : no-cache
Date                          : Fri, 07 Sep 2018 23:40:00 GMT

Body:
{
  "value": []
}

DEBUG: 20:40:00 - GetAzureResourceCmdlet end processing.
DEBUG: 20:40:00 - GetAzureResourceCmdlet end processing.
markcowl commented 6 years ago

@lwajswaj I don't see the error mentioned in this repro - is this the cmdlet invocation that produced the error?

Also, after producing the error, in addition to the Debug log, can you provide the results of runnign Resolve-AzureRmError

lwajswaj commented 6 years ago

It's not an actual error, it's that I don't get anything. when I run this line

 $vip = Get-AzureRmResource -ResourceGroupName ResourceGroupName -ResourceType Microsoft.Web/hostingEnvironments/capacities -ResourceName ASEName/virtualip -debug -ApiVersion 2018-02-01

I get nothing although in the response the data is there, it doesn't get processed

markcowl commented 6 years ago

@lwajswaj Got it, thanks.

cormacpayne commented 6 years ago

@Tiano2017 looking at the first scenario, where the user is providing both the -ResourceId and -ApiVersion parameters, the generic HttpClient is used to make the call rather than the ARM SDK (second scenario), and a resposne is received, but is not parsed. Would you know why this would occur?

balintbako commented 5 years ago

Still an issue in 6.13.1 release

IanMercer commented 5 years ago

This also prevents the ASE ILB address from being available to use as the output of an ARM template.

InternalServerError: ResourceDeploymentFailure
The response for resource had empty or invalid content
kdevesh commented 4 years ago

Is there any update on this issue. I am still not able to see ILB ip with the above command. In ARM template also i am not able to retrieve it.

murdockcrc commented 4 years ago

I concur. I am trying to get the internalIpAddress from resource /capacities/virtualip, but ARM deployment fails with error The response for resource had empty or invalid content. I am using the following method to try to retrieve this value:

"[reference(resourceId('Microsoft.Web/hostingEnvironments/capacities/', parameters('aseName'), 'virtualip'), '2019-08-01', 'Full').internalIpAddress]"
kdevesh commented 4 years ago

@murdockcrc /capacities/virtualip won't work due to the above issue.You can get the ip after deploying appservice in ase plan.This is kind a workaround

murdockcrc commented 4 years ago

@kdevesh do I have to deploy a web app, or would an app service plan suffice?

kdevesh commented 4 years ago

@murdockcrc in order to deploy a web app you need an app service plan.You can create the app service plan in the ASE and then create the web app from there you can get the IP address

murdockcrc commented 4 years ago

I managed to use a workaround with powershell. But if the internal private frontend IP address is already available in the portal and in resources.azure.com, I believe this same value should be retrievable via ARM. I'd suggest for the team to take a look at this and extend the functionality of the ARM RP. Thx.

HQJaTu commented 4 years ago

As I'm failing to get the addresses after creating ASP and Azure Portal has the IPv4-addresses on newly created ASE without ASP, I'm getting the values from API https://docs.microsoft.com/en-us/rest/api/appservice/appserviceenvironments/getvipinfo.

The obvious problem is to gain access to the required bearer token. As I need the token for other API-calls which are not available as PowerShell cmdlets, it's not a big thing.

murdockcrc commented 4 years ago

I can still repro the error, even though there is already an app service plan and a web app deployed on the ASE. The following Posh command returns empty:

Get-AzureRmResource -ResourceGroupName "ResourceGroupName" -ResourceType Microsoft.Web/hostingEnvironments/capacities -ResourceName ASEName/virtualip

The same value can be retrieved with azcli successfully. Seems to be indeed a bug in powershell:

az resource show --ids $aseFullId --query "internalIpAddress"
ezgambac commented 4 years ago

After debugging the code, I found that the response for Microsoft.Web/hostingEnvironments/capacities in the powershell get resource doesn't follow a format that works for serialization.

The RP is returning, for example, this:

{ "serviceIpAddress": "52.224.160.164", "internalIpAddress": "10.0.0.11", "outboundIpAddresses": [ "52.224.160.164" ], "vipMappings": []}

It should return something more like this, (this is a public ip object, note that it has id, name, type, location and other things)

{{ "id": "/subscriptions/0dffc609-7841-43d0-a884-60eb80d1a19c/resourceGroups/github_ezgambac_ps_issue/providers/Microsoft.Network/publicIPAddresses/AzFirewall-pip", "name": "AzFirewall-pip", "type": "Microsoft.Network/publicIPAddresses", "sku": { "name": "Standard" }, "location": "eastus", "tags": { "tag1": "value1", "tag2": "value2" }}}

I think the response the RP is sending should be part of the properties property in the resource class (https://github.com/Azure/azure-powershell/blob/master/src/Resources/ResourceManager/Entities/Resources/Resource.cs).

The response from the RP should be able to be parsed as that c# object.

artmasa commented 3 years ago

When will this resource type return a valid resource structure?

{
  "id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.Web/hostingEnvironments/{ase-name}/capacities/virtualip",
  "name": "virtualip",
  "properties": {
    "serviceIpAddress": "x.x.x.x",
    "internalIpAddress": "x.x.x.x",
    "outboundIpAddresses": [
       "x.x.x.x"
    ],
    "vipMappings": []
  }
}

Is it that hard to fix? it's been more than 2 years

this is what we get today

{
    "serviceIpAddress": "x.x.x.x",
    "internalIpAddress": "x.x.x.x",
    "outboundIpAddresses": [
       "x.x.x.x"
    ],
    "vipMappings": []
}

It's really hard to automate these deployments. Service plans are planned outside of the ASE deployment. We need to deploy:

Then other teams deploy Service Plans based on requirements

jim-022 commented 3 years ago

Any update on that ?

apwestgarth commented 3 years ago

@madsd is this something you can assist with?

panchagnula commented 3 years ago

@madsd is this something you can assist with?

@apwestgarth looking at this - this is using an API directly & not specific to an App Service command. I will let @madsd comment as well - but might be API related .

panchagnula commented 3 years ago

Thanks @madsd & @miwebst . @MartinAngelov As per the ASE team this was fixed with api-version 2019-08-01 & higher so change the command to use this api-version & this should work.

KanishkT123 commented 3 years ago

ARM Template Solution

For anyone who comes here from Google in the future: How to access the Internal IP address of an ILB ASE (Internal Load Balancer App Service Environment) through an ARM Template.

The following reference function works for me:

"[reference(resourceId('Microsoft.Web/hostingEnvironments/capacities/', variables('aseName'), 'virtualip'), '2019-08-01', 'Full')]"

And the full object has the internalIpAddress, which you can get using:

"value": "[reference(resourceId('Microsoft.Web/hostingEnvironments/capacities/', variables('aseName'), 'virtualip'), '2019-08-01', 'Full').properties.internalIpAddress]"

I believe that any API version after 2019-08-01 should also work, but my only evidence for that is @panchagnula 's comment.

I think this theoretically fully resolves this issue?