c# - Publishing Azure Mobile Service doesn't work -
i have azure mobile service works locally , has been thoroughly tested using fiddler. setup reference handling avoid self referencing loops
webapiconfig.cs
public static class webapiconfig { public static void register() { // use class set configuration options mobile service configoptions options = new configoptions(); // use class set webapi configuration options httpconfiguration config = serviceconfig.initialize(new configbuilder(options)); jsonconvert.defaultsettings = () => new jsonserializersettings { formatting = newtonsoft.json.formatting.indented, referenceloophandling = referenceloophandling.ignore }; config.includeerrordetailpolicy = includeerrordetailpolicy.always; // display errors in browser during development, uncomment following // line. comment out again when deploy service production use. // config.includeerrordetailpolicy = includeerrordetailpolicy.always; database.setinitializer(new mobileserviceinitializer()); }
my context pretty simple
public class saservicecontext : dbcontext { private const string connectionstringname = "name=ms_tableconnectionstring"; public saservicecontext() : base(connectionstringname) { } public dbset<recipe> recipes { get; set; } public dbset<method> methods { get; set; } public dbset<recipeitem> items { get; set; } public dbset<diettype> diettypes { get; set; }... protected override void onmodelcreating(dbmodelbuilder modelbuilder) { string schema = servicesettingsdictionary.getschemaname(); if (!string.isnullorempty(schema)) { modelbuilder.hasdefaultschema(schema); } modelbuilder.conventions.add( new attributetocolumnannotationconvention<tablecolumnattribute, string>( "servicetablecolumn", (property, attributes) => attributes.single().columntype.tostring())); } }
as said works locally , when publish service cloud can see ms_tableconnectionstring ok service not work. starts ok , can see relevant methods tablecontrollers click 1 (eg getseason) generic error
an exception has occurred while using formatter 'jsonmediatypeformatter' generate sample media type 'application/json'. exception message: 1 or more errors occurred.
i have tried
preservereferenceshandling = preservereferenceshandling.objects
but no avail. noted tables not being created in sql azure never gets database initilaizer method called webapiconfig. logs in ms azure portal arent showing errors either. im stuck appreciated
edit seeing following error in azure portal. ms_tableconnectionstring auto created in azure not sure why saying thats problem. locally use connectionstring in web.config
exception=system.invalidoperationexception: database initialization failed. not initialize 1 or more objects in schema 'smallacorns_v3'. please ensure database connection string correct. more details on error, please see inner exception. ---> system.invalidoperationexception: database initialization failed. not initialize 1 or more objects in schema 'smallacorns_v3'. please ensure database connection string correct. more details on error, please see inner exception. ---> system.data.sqlclient.sqlexception: user not have permission perform action.
this looks user using connecting azure sql database doesn't have permissions create azure sql database.
try giving database user, 'db_owner' role , error should go away.
Comments
Post a Comment