azure-sdk-for-go icon indicating copy to clipboard operation
azure-sdk-for-go copied to clipboard

Unexpected Error when trying to create PostgreSQL Flexi Server

Open vishwakalyanaraman opened this issue 2 years ago • 4 comments

I'm trying to create a PostgreSQL Flexi server using the SDK but I am running into an unexpected error when trying to do so.

This is the code that I'm using to create the server:

serverPoller, err := serverSVC.BeginCreate(
        ctx,
	data.ResourceGroup,
	data.ServerName,
	armpostgresqlflexibleservers.Server{
		Location: &data.Location,
		Properties: &armpostgresqlflexibleservers.ServerProperties{
			AdministratorLogin:         &data.AdminUsername,
			AdministratorLoginPassword: &data.AdminPassword,
			Version:                    &data.ServerVersion,
			Network: &armpostgresqlflexibleservers.Network{
				DelegatedSubnetResourceID:   &data.SubnetID,
				PrivateDNSZoneArmResourceID: &data.DnsID,
				PublicNetworkAccess:         &data.PublicIPDisabled,
			},
			Storage: &armpostgresqlflexibleservers.Storage{
				StorageSizeGB: to.Ptr[int32](1024),
			},
			HighAvailability: &armpostgresqlflexibleservers.HighAvailability{
				Mode: &data.HaDisabled,
			},
		},
		SKU: &armpostgresqlflexibleservers.SKU{
			Tier: &data.SkuTier,
			Name: to.Ptr("Standard_B1ms"),
		},
	},
	nil,
)

This is the response from the API call:

[GET https://management.azure.com/subscriptions/<subscription-id>/providers/Microsoft.DBforPostgreSQL/locations/westus/azureAsyncOperation/9f8525f1-c054-4256-935b-e4190535f57c
--------------------------------------------------------------------------------
    RESPONSE 200: 200 OK
    ERROR CODE: InternalServerError
--------------------------------------------------------------------------------
    {
      "name": "9f8525f1-c054-4256-935b-e4190535f57c",
      "status": "Failed",
      "startTime": "2022-07-06T11:39:29.997Z",
      "error": {
        "code": "InternalServerError",
        "message": "An unexpected error occured while processing the request. Tracking ID: '20c6992d-9c1c-483d-b11a-d9491bbbd178'"
      }
    }
--------------------------------------------------------------------------------
    ]

I'm using github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresqlflexibleservers v1.0.0 in my code

I am also able to successfully create a PostgreSQL server via the Azure Portal with the same parameters as my code.

vishwakalyanaraman avatar Jul 06 '22 12:07 vishwakalyanaraman

Looks like this was an error due to the parameters I was passing for SKU. There doesn't seem to be validations for which Tier/Name combinations work as defined by this document: https://docs.microsoft.com/en-us/azure/postgresql/flexible-server/concepts-compute-storage#compute-tiers-vcores-and-server-types

It would be great to add these validations to the library instead of sending across an InternalServerError here.

vishwakalyanaraman avatar Jul 07 '22 04:07 vishwakalyanaraman

Thank you for your feedback. This has been routed to the support team for assistance.

msftbot[bot] avatar Jul 07 '22 05:07 msftbot[bot]

@vishwakalyanaraman Thanks for your feedback. All our Go mgmt. SDKs are auto generated from service swagger definitions. In swagger, sku name is just a string. I'll let service team to take a look. @navba-MSFT I think there are two things here: 1. service need to return a clearly error to indicate the sku name is not valid instead of an internal server error. 2. either change sku name into an un-sealed enum or add some doc for the string value will help customer to know how to set the value.

tadelesh avatar Jul 07 '22 05:07 tadelesh

@vishwakalyanaraman @tadelesh Thanks for bringing this to our attention. I am adding the service team to look into this.

@sunilagarwal, @lfittl-msft, @sr-msft, @niklarin @DaeunYim Could you please look into this and provide some pointers when you get a chance ? Awaiting your reply.

navba-MSFT avatar Jul 07 '22 06:07 navba-MSFT

@vishwakalyanaraman @tadelesh Thanks for bringing this to our attention. I am adding the service team to look into this.

@sunilagarwal, @lfittl-msft, @sr-msft, @niklarin @DaeunYim Could you please look into this and provide some pointers when you get a chance ? Awaiting your reply.

Any update?

RickWinter avatar Sep 01 '22 21:09 RickWinter