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 Plans: Json Unmarshalling Bug #841

Closed
tombuildsstuff opened this issue Dec 28, 2016 · 2 comments
Closed

App Service Plans: Json Unmarshalling Bug #841

tombuildsstuff opened this issue Dec 28, 2016 · 2 comments
Assignees
Labels
App Services P1 Service Attention Workflow: This issue is responsible by Azure service team.

Comments

@tombuildsstuff
Copy link
Contributor

tombuildsstuff commented Dec 28, 2016

👋 me again

I was implementing support for App Service Plans / Server Farms - and encountered a bug in the SDK.

Request:

PUT /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tfasprg/providers/Microsoft.Web/serverfarms/tfaspexample?allowPendingState=false&api-version=2015-08-01

 {"name":"tfaspexample","kind":"app","location":"westus","tags":{},"properties":{"name":"tfaspexample","maximumNumberOfWorkers":1},"sku":{"name":"S1","tier":"Standard","size":"S1","family":"S","capacity":1}}

..which redirects too the following URL to Poll for the outcome:

https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tfasprg/providers/Microsoft.Web/serverFarms/tfaspexample/operationresults/00000000-0000-0000-0000-000000000000?allowPendingState=false&api-version=2015-08-01

which gives the following Response:

{
	"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tfasprg/providers/Microsoft.Web/serverfarms/tfaspexample",
	"name": "tfaspexample",
	"type": "Microsoft.Web/serverfarms",
	"kind": "app",
	"location": "West US",
	"tags": {},
	"properties": {
		"serverFarmId": 0,
		"name": "tfaspexample",
		"workerSize": 0,
		"workerSizeId": 0,
		"workerTierName": null,
		"numberOfWorkers": 1,
		"currentWorkerSize": 0,
		"currentWorkerSizeId": 0,
		"currentNumberOfWorkers": 1,
		"status": 0,
		"webSpace": "tfasprg-WestUSwebspace",
		"subscription": "00000000-0000-0000-0000-000000000000",
		"adminSiteName": null,
		"hostingEnvironment": null,
		"hostingEnvironmentProfile": null,
		"maximumNumberOfWorkers": 10,
		"planName": "VirtualDedicatedPlan",
		"adminRuntimeSiteName": null,
		"computeMode": 0,
		"siteMode": null,
		"geoRegion": "West US",
		"perSiteScaling": false,
		"numberOfSites": 0,
		"hostingEnvironmentId": null,
		"tags": {},
		"kind": "app",
		"resourceGroup": "tfasprg",
		"reserved": false,
		"mdmId": "waws-prod-bay-021_19817",
		"targetWorkerCount": 0,
		"targetWorkerSizeId": 0,
		"provisioningState": "Succeeded"
	},
	"sku": {
		"name": "S1",
		"tier": "Standard",
		"size": "S1",
		"family": "S",
		"capacity": 1
	}
}

In the response, the field status is returned as an Integer - however as defined in the Go SDK it's an StatusOptions - which is an Enum:

// ServerFarmWithRichSku is app Service Plan Model
type ServerFarmWithRichSku struct {
	autorest.Response                `json:"-"`
	ID                               *string             `json:"id,omitempty"`
	Name                             *string             `json:"name,omitempty"`
	Kind                             *string             `json:"kind,omitempty"`
	Location                         *string             `json:"location,omitempty"`
	Type                             *string             `json:"type,omitempty"`
	Tags                             *map[string]*string `json:"tags,omitempty"`
	*ServerFarmWithRichSkuProperties `json:"properties,omitempty"`
	Sku                              *SkuDescription `json:"sku,omitempty"`
}

// ServerFarmWithRichSkuProperties is
type ServerFarmWithRichSkuProperties struct {
	Name                      *string                    `json:"name,omitempty"`
	WorkerTierName            *string                    `json:"workerTierName,omitempty"`
	Status                    StatusOptions              `json:"status,omitempty"`
	Subscription              *string                    `json:"subscription,omitempty"`
	AdminSiteName             *string                    `json:"adminSiteName,omitempty"`
	HostingEnvironmentProfile *HostingEnvironmentProfile `json:"hostingEnvironmentProfile,omitempty"`
	MaximumNumberOfWorkers    *int32                     `json:"maximumNumberOfWorkers,omitempty"`
	GeoRegion                 *string                    `json:"geoRegion,omitempty"`
	PerSiteScaling            *bool                      `json:"perSiteScaling,omitempty"`
	NumberOfSites             *int32                     `json:"numberOfSites,omitempty"`
	ResourceGroup             *string                    `json:"resourceGroup,omitempty"`
	Reserved                  *bool                      `json:"reserved,omitempty"`
}

// StatusOptions enumerates the values for status options.
type StatusOptions string

const (
	// StatusOptionsPending specifies the status options pending state for
	// status options.
	StatusOptionsPending StatusOptions = "Pending"
	// StatusOptionsReady specifies the status options ready state for status
	// options.
	StatusOptionsReady StatusOptions = "Ready"
)

The specific Exception that I'm seeing is:

Error occurred unmarshalling JSON - Error = 'json: cannot unmarshal number into Go value of type web.StatusOptions' JSON = '........'

I'm assuming this would need a fix in the API, rather than the Swagger?

Thanks! :)

@kirthik
Copy link
Contributor

kirthik commented Apr 11, 2017

Closing since this was fixed on the service side.

@tombuildsstuff
Copy link
Contributor Author

Thanks @kirthik :)

@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 P1 Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

7 participants