I have an Azure Function I deploy as a part of an ARM template. This Azure Function references a few external .NET DLLs. I have added the reference to these DLLs in the project.json file:
project.json:
{"frameworks": {"net46": {"dependencies": {"Microsoft.IdentityModel.Clients.ActiveDirectory":"3.13.8","Newtonsoft.Json": "10.0.2","Microsoft.CrmSdk.CoreAssemblies" : "8.2.0.2" } } } }
When I click run, the Nuget Cache restore is kicked off. It fails with "The user name or password is incorrect."
The strange thing is the Nuget Packages are being copied to the Functions Nuget cache correctly, but the project.lock.json file is failing to be created. It appears the username / password error is thrown after the Nuget cache restore completes and when Azure tries to write the project.lock.json file. The compile then fails as the project.lock.json file is not created.
2017-11-14T21:06:34.892 Restoring packages.2017-11-14T21:06:34.892 Starting NuGet restore2017-11-14T21:06:36.239 Function started (Id=1340feea-174d-4bee-97f2-e06afc2e2d6e)2017-11-14T21:06:36.239 Package references have been updated.2017-11-14T21:06:36.239 Restoring packages.2017-11-14T21:06:36.239 Starting NuGet restore2017-11-14T21:06:36.955 Restoring packages for D:\home\site\wwwroot\ProvisionUserToCRM\project.json...2017-11-14T21:06:37.456 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel.clients.activedirectory/index.json2017-11-14T21:06:37.486 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel.clients.activedirectory/3.13.8/microsoft.identitymodel.clients.activedirectory.3.13.8.nupkg2017-11-14T21:06:37.705 CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json2017-11-14T21:06:37.705 CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/10.0.2/newtonsoft.json.10.0.2.nupkg2017-11-14T21:06:37.800 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.crmsdk.coreassemblies/index.json2017-11-14T21:06:37.800 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.crmsdk.coreassemblies/8.2.0.2/microsoft.crmsdk.coreassemblies.8.2.0.2.nupkg2017-11-14T21:06:37.881 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel/index.json2017-11-14T21:06:37.881 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel/6.1.7600.16394/microsoft.identitymodel.6.1.7600.16394.nupkg2017-11-14T21:06:38.002 Installing Microsoft.IdentityModel 6.1.7600.16394.2017-11-14T21:06:38.362 Installing Microsoft.CrmSdk.CoreAssemblies 8.2.0.2.2017-11-14T21:06:38.939 Restoring packages for D:\home\site\wwwroot\ProvisionUserToCRM\project.json...2017-11-14T21:06:39.113 Installing Newtonsoft.Json 10.0.2.2017-11-14T21:06:39.255 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel.clients.activedirectory/index.json2017-11-14T21:06:39.284 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel.clients.activedirectory/3.13.8/microsoft.identitymodel.clients.activedirectory.3.13.8.nupkg2017-11-14T21:06:39.455 CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json2017-11-14T21:06:39.455 CACHE https://api.nuget.org/v3-flatcontainer/newtonsoft.json/10.0.2/newtonsoft.json.10.0.2.nupkg2017-11-14T21:06:39.470 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.crmsdk.coreassemblies/index.json2017-11-14T21:06:39.470 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.crmsdk.coreassemblies/8.2.0.2/microsoft.crmsdk.coreassemblies.8.2.0.2.nupkg2017-11-14T21:06:39.490 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel/index.json2017-11-14T21:06:39.502 CACHE https://api.nuget.org/v3-flatcontainer/microsoft.identitymodel/6.1.7600.16394/microsoft.identitymodel.6.1.7600.16394.nupkg2017-11-14T21:06:39.642 Installing Microsoft.IdentityModel.Clients.ActiveDirectory 3.13.8.2017-11-14T21:06:41.211 Installing Microsoft.IdentityModel 6.1.7600.16394.2017-11-14T21:06:42.367 Installing Microsoft.CrmSdk.CoreAssemblies 8.2.0.2.2017-11-14T21:06:46.398 Installing Microsoft.IdentityModel.Clients.ActiveDirectory 3.13.8.2017-11-14T21:06:49.197 Installing Newtonsoft.Json 10.0.2.2017-11-14T21:06:52.171 The user name or password is incorrect.2017-11-14T21:06:52.189 2017-11-14T21:06:52.189 2017-11-14T21:06:52.189 Packages restored.2017-11-14T21:06:52.500 Script for function 'ProvisionUserToCRM' changed. Reloading.2017-11-14T21:06:52.813 run.csx(2,18): error CS0234: The type or namespace name 'IdentityModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)2017-11-14T21:06:52.813 run.csx(3,8): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
Does anyone know why this error is displayed? It seems to come intermittently for me. Seems like a bug in Azure Functions. Are there any known work arounds?
I found enabling 'Slots' preview feature on Azure Functions actually resolves this issue, but 'Slots' will not work for me as they are not compatible with Azure Logic Apps.