Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.3k stars 431 forks source link

Azurite Support #1247

Open ahmedelnably opened 5 years ago

XiaoningLiu commented 4 years ago

Hi @ahmedelnably This is Xiaoning from Azurite dev team. Recently we got more and more customer trying Azure Function with Azurite. Some of them have issues. However, me & our team lack much knowledge of Azure Function and how does Azure Function extension calling into Azurite, we cannot give solutions for the customers. Expecially we cannot locate which request sent to Azurite is failed or unexpected. It's better we can get help from your team with the investigation and locate the requests related to the failure.

Currently, we have following issues related with Azure Functions.

https://github.com/Azure/Azurite/issues/268 https://github.com/Azure/Azurite/issues/263 https://github.com/Azure/Azurite/issues/251 https://github.com/Azure/Azurite/issues/246 https://github.com/Azure/Azurite/issues/37

@blueww

ygoldenberg-paradigm commented 4 years ago

I recently tried using the latest version Azurite with Azure Functions and I had the following issues:

ahmedelnably commented 4 years ago

cc/ @fabiocav We are aware of the issues caused by using Azurite with the Core Tools, we are still recommending users to use the Storage emulator until we completely support Azurite (and Azurite have feature parity with the emulator in the parts needed for running functions locally, like support for table storage)

XiaoningLiu commented 4 years ago

Thanks @ahmedelnably! There are some backgrounds in storage team. Existing Azure Storage Emulator based on .Net is not going to have new storage features update in favor of Azurite. But Table support for Azurite is not planned by storage team. Table emulation will be supported by Cosmos DB emulator.

ygoldenberg-paradigm commented 4 years ago

@XiaoningLiu I'm having an issue with the existing storage emulator. The existing storage emulator crashes with a blob path longer than 256 characters. When using the blob trigger, the blob trigger creates a blob path from the existing blob, and adds additional data to the blob name, which in my case shortens the available number of characters to below 180. This does not happen in Production Azure storage, so I don't want to impose a character limit on the application just for development needs. I seem to not have this issue with Azurite, but I am having issues using Azurite due to the need for Table Storage. Is table support already available in Cosmos DB emulator, and can that be used together with Azurite now, or is that feature still being worked on? For now I've resorted to using real live Azure Storage for development to get around this issue.

XiaoningLiu commented 4 years ago

@ygoldenberg-paradigm Cosmos DB emulator supports Table API, but it's currently only on Windows. https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator

JustinGrote commented 4 years ago

@ahmedelnably any plans to port the storage emulator to .NET Core and make it work cross platform? Without that developers only options are Azurite or developing directly against azure resources (that includes CI/CD testing of functions).

ahmedelnably commented 4 years ago

@JustinGrote that would be a question to @XiaoningLiu and the Azure Storage team

JustinGrote commented 4 years ago

@ahmedelnably Since last discussion, it has been made news that Azure Storage Emulator is discontinued and Azurite is the preferred emulator going forward by Microsoft, so we need to make it a priority to get this working with Azure Functions. As of Azurite 3.6.0 it's looking to me like the blob and queue output bindings are working fine at a simple level.

Currently the only blocking issue I see for durable functions is https://github.com/Azure/Azurite/issues/268#issuecomment-599877061 where azurite returns a 409 when it should return a 201, so hopefully an azurite resource like @XiaoningLiu can correct that behavior.

XiaoningLiu commented 4 years ago

Hi @JustinGrote, thanks for your investigation, but the pointed code is by design in Azurite.

Azure Storage has the same behavior and will return 409, if:

Actually this is a scenario about atomic "createIfNotExist" operation.

There should some other places make the difference. For example, before the put blob request mentioned, there is a delete request to existing blob, Azure Storage deletes successfully, while Azurite failed. Then comes to the put blob 409. We need more evidences if possible.

JustinGrote commented 4 years ago

I saw that, but what I'm saying is that simply it works with emulator and live accounts but not with azurite, and if I patch out this code, it works.

If you want to drive azurite adoption I'd look into a compatibility flag for this quirk unless a more nuanced reason can be found.

shaunco commented 4 years ago

With Azurite running local or in a local Docker, the Azure Functions Core Tools still tries to run "AzureStorageEmulator.exe start", which causes Visual Studio (2019) to hang for about 2 minutes and then finally report that it was unable to start the Azure Storage Emulator (because the ports are in use), and then it refuses to start the functions runtime. All seems good if I change local.settings.json to use a full connection string to Azurite:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;",
  }
}

instead of

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
  }
}

Not a terribly difficult workaround, but given that

Azure Storage Emulator is discontinued and Azurite is the preferred emulator going forward by Microsoft

It would seem that Azure Functions Core Tools should just work seamlessly with Azurite, or at least document the above change somewhere...

flq commented 3 years ago

So, after copious amounts of Yak shaving it all boils down to azurite not supporting table storage, right?

So on one hand MS says "use azurite". On the other hand, azure core tools' function host won't work properly with azurite, because table storage is missing.

So, what's the guidance here and also especially for non-windows computers?

JustinGrote commented 3 years ago

@flq Azurite has a table storage "alpha" that does work with functions, but it would seem the "official" guidance is still to spin up an Azure Storage account in an azure subscription for non-windows.

https://github.com/Azure/Azurite/tree/table

Development on it looks like it is slowing down tho, no new commits in a month.