azure storage account - azure

I'm trying to deploy an application on Azure but I'm facing some problems.
on my dev box, all works fine but I have a problem when I'm trying to use the application once it is deployed.
on the dev box, I have an action that I do manually wich crates the test tables in my local sql server express.
but I do not know how to create the tables on the server ? so when I run my website application, it says TableNotFound.
Can sy guide me through this final step ? do I need to make sg additional ?
Thx in advance

The table storage client provides a method to create the schema in the cloud storage; I forget the name (will look it up in a second); call that when you initialise whatever you're using as your data service layer.
Edit: The following snippet is what I use:
StorageAccountInfo = StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration();
TableStorage.CreateTablesFromModel( typeof( <Context> ), info );
where <Context> is your data context object.

Related

Blazor WASM Azure Static Web App, Functions not working

I created a simple Blazor WASM webapp using C# .NET5. It connects to some Functions which in turn get some data from a SQL Server database.
I followed the tutorial of BlazorTrain: https://www.youtube.com/watch?v=5QctDo9MWps
Locally using Azurite to emulate the Azure stuff it all works fine.
But after deployment using GitHub Action the webapp starts but then it needs to get some data using the Functions and that fails. Running the Function in Postman results in a 503: Function host is not running.
I'm not sure what I need to configure more. I can't find the logging from Functions. I use the injected ILog, but can find the log messages in Azure Portal.
In Azure portal I see my 3 GET functions, but no option to test or see the logging.
With the help of #Aravid I found my problem.
Because I locally needed to tell my client the URL of the API I added a configuration in Client\wwwroot\appsettings.Development.json.
Of course this file doesn't get deployed.
After changing my code in Program.cs to:
var apiAddress = builder.Configuration["ApiAddress"] ?? $"{builder.HostEnvironment.BaseAddress}/api/";
builder.Services.AddHttpClient("Api",(options) => {
options.BaseAddress = new Uri(apiAddress);
});
My client works again.
I also added my SqlServer connection string in the Application Settings of my Static Web App and the functions are working as well.
I hope somebody else will benefit from this. Took me several hours to figure it out ;)

Azure Mobile Service (node backend) __updatedAt property not automatically set after edit

After reading the documentation I was expecting that this field is automatically set by Azure Mobile Services. Apparently it isn't.
Should I configure something extra?
Other options that I see (to do for each table):
* add an axtra line to the node js update(item, user, request) function:
item.__updatedAt = new Date();
* create an update trigger in the database
Anybody experience with this?
Thx!
The __updatedAt column is updated by a trigger created in the underlying SQL Server database, so it should be updated any time a row is updated. Note that this requires a database operation to occur for it to be updated.

SQL Server CE on Azure website

Trying to run SQL Server CE on an Azure website, but I am getting error:
Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8876. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details
You cannot use SQL Server CE on Azure Web Sites. Using Azure Web Sites you have to use external database - such as Azure SQL Database or MySQL.
Generally speaking for the cloud and any cloud service (IaaS, PaaS, SaaS), you shall never rely on local file system, but rather persist your files on a durable storage such as Azure Blob Storage. Thus you can't (shall not) use services like SQL Server CE.
This seems to work:
Reference System.Data.SqlServerCe 4.0, set "Copy Local" = true.
Azure runs as a an x86 process (not Amd):
Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
On dev machine find SQLServerCE dependencies:
C:\ProgramFiles\Microsoft SQL Server Compact Edition\v4.0\Private\x86
Create SqlServerCE\x86 folder in web project.
Copy x86 files into new x86 folder:
sqlceca40.dll
sqlcecompact40.dll
sqlceer40EN.dll
sqlceme40.dll
sqlceqp40.dll
sqlcese40.dll
Add this block to top of application_start in global.asax
string dest = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;
string src = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "SqlServerCE\\x86";
foreach (var file in Directory.GetFiles(src))
{
var fileinfo = new FileInfo(file);
string destpath = Path.Combine(dest, fileinfo.Name);
if (!File.Exists(destpath))
{
fileinfo.CopyTo(destpath);
}
}
Note: I am not happy with this solution but I can't figure out how to get the files into the bin folder on deployment. post build events don't seem to work. If anyone has a better solution please suggest it.

azure table storage query

when I Post data and Query a Table with the database as: Dev datastorage (emulator) it works.
When I Post data Table with the data in Azure data base (have account) it works.
When I Get data from Table with the data in Azure data base (have account) it does not works.
In both the cases the code is the same.except the key and account credentials.
Is it I should do anything to Query ?
var query = azure.TableQuery
.select().from('dummytable').where('PartitionKey eq ?', key);
can any one suggest why Query is not working.
should there be anything else that need to be done
From Storage Explorer it works, I am able to see the entities.
only from the program I am not able to get the response. But in the same program "PUT"operation is working.
Was happening the same to me.. did an upgrade from the azure npm package 0.6.1 to 0.6.7 and now works, hope this helps.
I would look at the value that is on your partition key. There are some values that aren't on the list of invalid characters that Azure has issue with. For example before SDK 1.7 you could safely insert a % in a key, but if you queried for it specifically it wouldn't work. To test if this is the problem try running your query but without the filter and make sure your row is returned.
After reading the msdn mailing lists, I have upgraded the azure npm with the latest package 0.6.7 and it works. looks to be an issue with azure

How-to: Create role instances on emulator

How do I create new instances of some role via C# using Azure emulator? Is there some guide about that? There are some manuals about creating instances in the cloud, not in emulator.
So far I know that:
I need to change config-file. Is it config in sln-file or in some temp-delpoyment folder?
I need to use csrun tool. How to pick params?
UPD
Got it.
To change count or instances on emulator, you have to:
update 'ServiceConfiguration.cscfg' file in bin-folder
run 'csrun' tool with params: string.Format("/update:{0};\"{1}\"", deploymentId, "<path to ServiceConfiguration.cscfg>")
where deploymentId:
// get id from RoleEnvironment with regex
var patternt = Regex.Escape("(") + #"\d+" + Regex.Escape(")");
var input = RoleEnvironment.DeploymentId;
var m = Regex.Match(input, patternt);
var deploymentId = m.ToString().Replace("(", string.Empty).Replace(")", string.Empty);
If you have troubles running csrun via code, read this:
http://social.msdn.microsoft.com/Forums/en/windowsazuredevelopment/thread/62ca1372-2388-4181-9dbd-8fbba470ea77
In local emulator, you need to modify the CSCFG file under the deployment .csx folder, instead of your source code folder, since the local emulator will fire your application up from that folder.
Once you modified the saved your CSCFG file, for example the count of the instances you can retrieve the new value from your code immediately. But if you want the local emulator detect this changes and perform the related actions, such as increase the VMs or invoke the Configuration_Changed method, you need to execute
csrun /update:;
You can retrieve the deployment id from the compute emulator UI.
You can find the instance count in the ServiceConfiguration.cscfg in your Azure project

Resources