Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App Service: API <-> SDK bug #938

Closed
tombuildsstuff opened this issue Feb 15, 2017 · 2 comments
Closed

App Service: API <-> SDK bug #938

tombuildsstuff opened this issue Feb 15, 2017 · 2 comments
Assignees
Labels
App Services P0 Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@tombuildsstuff
Copy link
Contributor

👋 ¡hōla!

I've been continuing on my quest to bring support for WebApps to Terraform - however I believe I've encountered some contract-related bugs in the API:

When I make the following Request via the Go SDK:

{
	"name": "tharvey-test-app",
	"kind": "app",
	"location": "South Central US",
	"tags": {
		"Demo": "true"
	},
	"properties": {
		"serverFarmId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Testdev/providers/Microsoft.Web/serverFarms/ServicePlan8c6045fa-97c4",
		"siteConfig": {
			"properties": {
				"numberOfWorkers": 21,
				"defaultDocuments": ["index.html"],
				"netFrameworkVersion": "4.5",
				"phpVersion": "",
				"pythonVersion": "",
				"nodeVersion": "",
				"use32BitWorkerProcess": false,
				"webSocketsEnabled": false,
				"alwaysOn": true,
				"javaVersion": ""
			}
		}
	}
}

The request succeeds and I get the following Response back from the API:

{
	"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Testdev/providers/Microsoft.Web/sites/tharvey-test-app",
	"name": "tharvey-test-app",
	"type": "Microsoft.Web/sites",
	"kind": "app",
	"location": "South Central US",
	"tags": {
		"Demo": "true"
	},
	"properties": {
		"name": "tharvey-test-app",
		"state": "Running",
		"hostNames": ["tharvey-test-app.azurewebsites.net"],
		"webSpace": "Testdev-SouthCentralUSwebspace",
		"selfLink": "https://waws-prod-sn1-037.api.azurewebsites.windows.net:454/subscriptions/00000000-0000-0000-0000-000000000000/webspaces/Testdev-SouthCentralUSwebspace/sites/tharvey-test-app",
		"repositorySiteName": "tharvey-test-app",
		"owner": null,
		"usageState": 0,
		"enabled": true,
		"adminEnabled": true,
		"enabledHostNames": ["tharvey-test-app.azurewebsites.net", "tharvey-test-app.scm.azurewebsites.net"],
		"siteProperties": {
			"metadata": null,
			"properties": [],
			"appSettings": null
		},
		"availabilityState": 0,
		"sslCertificates": null,
		"csrs": [],
		"cers": null,
		"siteMode": null,
		"hostNameSslStates": [{
			"name": "tharvey-test-app.azurewebsites.net",
			"sslState": 0,
			"ipBasedSslResult": null,
			"virtualIP": null,
			"thumbprint": null,
			"toUpdate": null,
			"toUpdateIpBasedSsl": null,
			"ipBasedSslState": 0,
			"hostType": 0
		}, {
			"name": "tharvey-test-app.scm.azurewebsites.net",
			"sslState": 0,
			"ipBasedSslResult": null,
			"virtualIP": null,
			"thumbprint": null,
			"toUpdate": null,
			"toUpdateIpBasedSsl": null,
			"ipBasedSslState": 0,
			"hostType": 1
		}],
		"computeMode": null,
		"serverFarm": null,
		"serverFarmId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Testdev/providers/Microsoft.Web/serverfarms/ServicePlan8c6045fa-97c4",
		"reserved": false,
		"lastModifiedTimeUtc": "2017-02-14T12:11:21.82",
		"storageRecoveryDefaultState": "Running",
		"contentAvailabilityState": 0,
		"runtimeAvailabilityState": 0,
		"siteConfig": null,
		"deploymentId": "tharvey-test-app",
		"trafficManagerHostNames": null,
		"sku": "Standard",
		"premiumAppDeployed": null,
		"scmSiteAlsoStopped": false,
		"targetSwapSlot": null,
		"hostingEnvironment": null,
		"hostingEnvironmentProfile": null,
		"microService": "WebSites",
		"gatewaySiteName": null,
		"clientAffinityEnabled": true,
		"clientCertEnabled": false,
		"hostNamesDisabled": false,
		"domainVerificationIdentifiers": null,
		"kind": "app",
		"outboundIpAddresses": "104.210.153.33,104.210.153.25,104.210.155.255,104.210.156.243",
		"containerSize": 0,
		"dailyMemoryTimeQuota": 0,
		"suspendedTill": null,
		"siteDisabledReason": 0,
		"functionExecutionUnitsCache": null,
		"maxNumberOfWorkers": null,
		"homeStamp": "waws-prod-sn1-037",
		"cloningInfo": null,
		"hostingEnvironmentId": null,
		"tags": {
			"Demo": "true"
		},
		"resourceGroup": "Testdev",
		"defaultHostName": "tharvey-test-app.azurewebsites.net",
		"slotSwapStatus": null
	}
}

However on deserialization I get the following exception:

web.SitesClient#GetSite: Failure responding to request: StatusCode=200 -- Original Error: Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal number into Go value of type web.UsageState' JSON = '

I believe the API is returning the Integer value of the UsageState Enum - as opposed to the String value which the Swagger expects - which can be seen in the following snippets from the Go SDK:

// UsageState enumerates the values for usage state.
type UsageState string

const (
	// UsageStateExceeded specifies the usage state exceeded state for usage
	// state.
	UsageStateExceeded UsageState = "Exceeded"
	// UsageStateNormal specifies the usage state normal state for usage state.
	UsageStateNormal UsageState = "Normal"
)

...

// SiteProperties is
type SiteProperties struct {
	Name                      *string                    `json:"name,omitempty"`
	State                     *string                    `json:"state,omitempty"`
	HostNames                 *[]string                  `json:"hostNames,omitempty"`
	RepositorySiteName        *string                    `json:"repositorySiteName,omitempty"`
	UsageState                UsageState                 `json:"usageState,omitempty"`
	Enabled                   *bool                      `json:"enabled,omitempty"`
	EnabledHostNames          *[]string                  `json:"enabledHostNames,omitempty"`
	AvailabilityState         SiteAvailabilityState      `json:"availabilityState,omitempty"`
	HostNameSslStates         *[]HostNameSslState        `json:"hostNameSslStates,omitempty"`
	ServerFarmID              *string                    `json:"serverFarmId,omitempty"`
	LastModifiedTimeUtc       *date.Time                 `json:"lastModifiedTimeUtc,omitempty"`
	SiteConfig                *SiteConfig                `json:"siteConfig,omitempty"`
	TrafficManagerHostNames   *[]string                  `json:"trafficManagerHostNames,omitempty"`
	PremiumAppDeployed        *bool                      `json:"premiumAppDeployed,omitempty"`
	ScmSiteAlsoStopped        *bool                      `json:"scmSiteAlsoStopped,omitempty"`
	TargetSwapSlot            *string                    `json:"targetSwapSlot,omitempty"`
	HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"`
	MicroService              *string                    `json:"microService,omitempty"`
	GatewaySiteName           *string                    `json:"gatewaySiteName,omitempty"`
	ClientAffinityEnabled     *bool                      `json:"clientAffinityEnabled,omitempty"`
	ClientCertEnabled         *bool                      `json:"clientCertEnabled,omitempty"`
	HostNamesDisabled         *bool                      `json:"hostNamesDisabled,omitempty"`
	OutboundIPAddresses       *string                    `json:"outboundIpAddresses,omitempty"`
	ContainerSize             *int32                     `json:"containerSize,omitempty"`
	MaxNumberOfWorkers        *int32                     `json:"maxNumberOfWorkers,omitempty"`
	CloningInfo               *CloningInfo               `json:"cloningInfo,omitempty"`
	ResourceGroup             *string                    `json:"resourceGroup,omitempty"`
	IsDefaultContainer        *bool                      `json:"isDefaultContainer,omitempty"`
	DefaultHostName           *string                    `json:"defaultHostName,omitempty"`
}

Upon further inspection of the Response - I believe that this is the case for the other Enum's within the Go SDK package too - to pick from the JSON in this case:

  • siteDisabledReason
  • contentAvailabilityState
  • runtimeAvailabilityState
  • ipBasedSslState
  • sslState
  • hostType
  • availabilityState

I've previously filed issue #841 which is very similar - and I'm wondering if this affects the other Enum related fields in the WebApps SDK? Would it be possible for someone to take a look into this for me please? Thanks in advance :)

Related: I'm aware this Repository is technically for the Swagger rather than API bugs - please let me know if I should be filing these kind of issues somewhere else :)

Thanks!

@lstolyarov
Copy link

Hello,

I have also seen similar bugs in the API. I believe there are more instances that need to be inspected as they are returning Integer values instead of their respective Enum types. The additional list to the above is:

  • ManagedPipelineMode
  • SiteLoadBalancing

I also have a fork of the SDK which you can use for reference https://github.com/lstolyarov/azure-sdk-for-go.

Thanks.

@naveedaz
Copy link
Contributor

This was fixed on the service end a while ago. The GO SDK needs to be regenerated with the latest swagger. The Azure SDK team is working on that.

@kirthik kirthik closed this as completed Apr 11, 2017
@bsiegel bsiegel added the Service Attention Workflow: This issue is responsible by Azure service team. label Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App Services P0 Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

5 participants