How to create a new Table using Table Storage in Azure - azure

I have tried to use the samples that Roger Jennings recommeded in his book, "Cloud Computing with Windows Azure", but he is using version 1. I'm using v1.2 and there is a lot of differences. Firstly, I had to recompile the StorageClient DLL with the corrected namespace and other changes. Then, when I use his code to create a Table at the application start, I get an "out of range index".
Has anyone managed to successfully create a Table at application startup? If so, how? Also, if there are any tutorials/samples that use version 1.2, I'd greatly appreciate them too.

You no longer have to rebuild the sample storage client library. v1.2 will automagically add three DLL references to your role:
Microsoft.WindowsAzure.Diagnostics
Microsoft.WindowAzure.ServiceRuntime
Microsoft.WindowsAzure.StorageClient
To create a table, you'll need to first set up your table :
Create a class deriving from TableServiceEntity (say, "MyEntity")-
Derive a table class from TableServiceContext (say, "MyEntityDataServiceContext"). In that class, create a property of type DataServiceQuery < MyEntity >() that returns CreateQuery < MyEntity > ("MyEntities");
Once you've done that, create the table with code like this:
var account = CloudStorageAccount.DevelopmentStorageAccount;
CloudTableClient.CreateTablesFromModel(typeof(MyEntityDataServiceContext),account.TableEndpoint.AbsoluteUri, account.Credentials);
For a much more detailed look at this, download the Azure Platform Training Kit. There's a lab called "Exploring Windows Azure Storage" that covers all this.

Related

IntelliJ IDEA azure ARM template intellisense

I am new to azure ARM templates... I would like to use IntelliJ IDEA, it has azure support plugin from Microsoft. I have whole project (java+maven+azure) in IDEA. I would like to work with related ARM template in the same place. ARM template documentation is huge... So, any in-IDE highlight/intellisense would be appreciated.
Problems:
when I open (regular file) JSON file (with schema) with ARM template
CTRL+SPACE shows possible values from schema, but it is really slow (like 8seconds) every time! Which makes it unusable. There isn't a cache of any type?
it does not offer all supported values, the latest "2019-04-01" is missing. But the schema contains it "$ref": "https://schema.management.azure.com/schemas/2019-04-01/Microsoft.Storage.json#/resourceDefinitions/storageAccounts"
CTRL+SPACE on location really shows list of possible locations. Unfortunately, it shows it "names" instead of IDs. "West Europe" vs. "westeurope". So it creates invalid template.
when I open deployment from Azure Explorer, it shows ARM template and its parameters in split view side-by-side. It is very fancy.
BUT... it do nothing to CTRL+SPACE.
split view keep changing widths all the times )-:
Questions:
How do you work with ARM templates?
Is it so slow for you too?
Is there somewhere a newer schema definition? (MS docs said that https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json# is latest)
I understand that half of it goes to IDEA team, half to azure plugin team... but it just seems to me, that I am doing something wrong.
... for anybody interested in ARM template in IntelliJ IDEA ...
IDEA is not currently (2020) ready for effective work (unfortunately). Azure Toolkit for IDEA plugin needs more work... lets hope for future releases.
Free Visual Studio Code with Azure resource manager extensions is smooth and fully integrated.

Where can i find the code of an Azure Function?

I'm new to Azure Functions and been thrown into a project without a proper introduction and anybody I could ask is out of office. My simple most likely stupid question is; where can I find the actual code?
In the azure portal, the functions are listed as "read-only" and only contains a function.json. The resource is an App Service and it has a couple of functions. There is no link to any git repository in properties.
Read-only Functions would be compiled and published (e.g. through Visual Studio or a CI/CD pipeline.) The Azure Functions Portal engineers are working on a new, improved experience for this but for now, if your Function app has a deployment source configured, you can view it from the Portal in two ways from your Function app:
Platform Features > Deployment Options.
Platform Features > Resource Explorer. In the file tree on the lefthand side, find your Function app's name, and under that, sourcecontrols. Click to expand in the righthand window.
If your Function app doesn't have a deployment source configured (e.g. your team has been publishing code manually) then things get harder. Depending on how your company has set up their source control and what you already have access to, the function.json you see might help: the entryPoint property in a build-generated function.json will give you the full assembly name of that function (e.g. VSSample.HelloSequence.Run). That or the assembly name of the uploaded DLL in the scriptfile property might help you locate the project.
Good luck! Keep posting if you have further questions; we're here to help.
AFAIK, if we create the azure function in the Visual Studio and publish it to Azure(there may be other ways), it will appear in the situation you described like the screenshot.
Actually, the code is existing in the portal, but the code has been compiled, you could access it in the Platform features -> Advanced tools (Kudu) -> Debug console.
If you want to get the .cs file, I think you should ask it for your coworkers, there will not be in azure.
You said that the Azure function is listed as "read-only". Did you check from the Application Settings menu if you can change the Azure function app edit mode to Read/Write?

How do I version Azure Functions so I can query at runtime?

I have an azure function that I want to report what version of the code it is running. In other applications I am able to get this by running something of the nature:
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
However I don't a) seem to have away of putting that data into the azure function (there is no assembly information button) or b) retrieving that information (the above code snippet always returns 1.0)
Is there a way (other than just putting in a configuration setting or private variable) to pull a standard version value from an Azure function via this mechanism?
I assume you are currently using .csx files from the Azure portal. If you instead switch to using Visual Studio and precompiled assemblies (which is generally recommended) the code you have above should work fine.
Specifically, use the following steps to change the version:
Right click on the Project and choose Properties
Go to 'Package'
Change the Package version

How do you tell entity framework to create / deploy a database in Azure?

I'm using Entity Framework with a code first model; I've got my InitialCreate migration setup and working locally, I can run code against my database context, and everything works.
But when I deploy my project to Azure, I just get a connection string error ("Format of the initialization string does not conform to specification starting at index 0.").
I can't seem to find where in the Publish dialog are the options to create the Azure database. -- Do I have to create the database separately and hook them up manually? -- If so, what exact process should I follow. Does the database need to have contents?
I thought Microsoft was making a big deal that this could all be done in a single deploy step, but that doesn't seem to be the case from my current experience.
When you publish your project in the publish dialog, there is an option for the code first migration in the Settings tab, it will automatically show your data context and it will give you the option to set the remote connection string, and this will add a section in web.config to specify the data context and the Migration class to run during the migration process.
It will also allow you to set if you want to run the code first Migration or not.
You can also take a backup from the dev and clear the data then upload it to Azure SQL DB, this way the code first data context will check at first connection and it will find the code an database the same

WCF model class from metadata not updating

I have a WCF service that uses a separate project for a DAL, which I have a reference to, and can access the entity objects with the DAL, through the service as such:
[OperationContract]
GeoLocations GetLocations();
This returns a GeoLocations object.
The issue is that I have updated the DAL as my database has changed, and I see all the new fields in the code, however when I do a 'view source' on GeoLocations I see the following file:
GeoLocations [from metadata]
... which doesn't contain any of the new fields, and is locked in the IDE.
I have tried cleaning the project, deleting all the DLL's, etc., but I still see the old class.
How can I update this with the new properties?
Thanks.
I faced such issue in many time and i found problem is related to this.
1.As you change in DAL. It is neccesarry that you build that project first.
WCF pproject as Reference of DAL. So you need to build this too and verify that it has updated DLL.
Now go to project and update service reference. of that Service in project or application where you consume your WCF service.
A couple of things:
When updating the service reference, depending on how large the service is that is being consumed, all the property definitions may not be updated right away. Also, after the service reference has been updated, I recommend building the project and then continuing. This seems to avoid the previous issue.

Resources