Tag: azure

AzureMobileService:将数据插入到表中会产生exception

我是新手来实施Azure移动服务。 我参考了Azure提供的ToDoItem演示。 以同样的方式,我已经为我自己的应用程序创建类User。 然后我将数据插入到MobileServiceTable中,但它给出了如下错误: {“message”:”The operation failed with the following error: ‘A null store-generated value was returned for a non-nullable member ‘CreatedAt’ of type ‘CrazyLabApp.Models.User’.’.”} 我没有创建任何这样的字段,因为它不是在ToDoItem演示中创建的。 我已经看到MobileServiceTable创建了4个默认字段。 createdAt是其中一个领域。 我很想知道我做错了什么。 检查我的以下用户类: public class User { @com.google.gson.annotations.SerializedName(“id”) private String ServiceUserId; @com.google.gson.annotations.SerializedName(“email”) private String Email; @com.google.gson.annotations.SerializedName(“firstname”) private String FirstName; @com.google.gson.annotations.SerializedName(“lastname”) private String LastName; @com.google.gson.annotations.SerializedName(“profilepic”) private String ProfilePic; @com.google.gson.annotations.SerializedName(“introduction”) […]

FileUpload文件名编码

我已经有一段时间了,因为我正在敲打这个:多部分/混合内容。 @RequestPart(name=”view”) CoolView, @RequestPart(name=”files”) Part [] files 也使用spring(因为CommonsMultipartResolver失败也没关系): StandardServletMultipartResolver 现在的问题是,当上传具有US_ASCII字符之外的某些名称的文件时,服务器会将它们转换为奇怪的东西。 奇怪的是,我的意思是它将它们转换为ISO_8859_1,我想我已经设想了UTF-8编码可以想象到的地方。 -Dfile.encoding = UTF-8 LANG =“en_US.UTF-8”LC_ALL =“en_US.UTF-8” URIEncoding = UTF-8(在server.xml中的tomcat) CharacterEncodingFilter是第一个被拾取的filter 有趣的是,这只发生在我在azure linux机器上尝试这个时,本地一切都很好。 例如,我使用curl发送一些要上传的文件: curl -X POST -F “files=@Définition fonctionnalités.pdf” 在Controller中,我试图查看实际从Content-Disposition文件名中捕获的名称。 Définition fonctionnalités.pdf 在这一点上,我会接受任何建议。 感谢你

Java – DocumentDB未经授权的访问

我正在尝试编写一个function来从Azure存储DocumentDB中的对象。 我有一段代码: public void saveEvent(Event event) throws DocumentClientException { Document document = new Document(JsonCreator.createJson(event)); //check if document already exists FeedOptions feedOptions = new FeedOptions(); feedOptions.setEnableCrossPartitionQuery(true); FeedResponse eventDocument = documentClient.queryDocuments(COLLECTION_LINK, String.format(SELECT_DOCUMENT, event.getId()), feedOptions); // if there is a document with the ID then replace if (eventDocument.getQueryIterator().hasNext()) { //documentClient.replaceDocument(COLLECTION_LINK, document, null); documentClient.replaceDocument(COLLECTION_LINK, document, null); } else { […]

无法连接Microsoft Azure Vm中的端口

我在Microsoft Azure中创建了Red Hat VM,并且能够通过ssh进行连接。 我已经在VM中使用端口8081启动了Java服务器并且它已成功启动。 但是我无法在浏览器中查看它。 它没有加载。 我尝试过以下内容,但所有内容都没有加载: – host:80 host:8080 host:8081 我已在网络安全组和相关子网中添加了入站安全规则。 我仍然无法在浏览器中查看我的服务器。 我已遵循此文档的入站安全规则 这是我的入境规则 netstat -tuplen (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State User […]

Application Insights使用log4j在java中进行日志记录

我最近发现应用程序见解有log4j扩展 。 因此,在线示例之后,我尝试配置应用程序洞察和log4j来记录生活在azure色托管tomcat中的servlet中的项目。 嗯,这个例子似乎非常不完整,因为它根本没有提到密钥。 通过查看源代码,我看到一个示例(测试?)在log4j.xml中使用 ,但没有太多关于如何使用或调试实际记录器的说明。 有没有人有关于如何实际使用/实现log4j的ApplicationInsightsAppender的指针? 这是github上的源代码https://github.com/Microsoft/ApplicationInsights-Java

如何在Android中使用Microsoft Translator API

用于Android示例的Microsoft Translator API自2017年3月起已被弃用(仅此一年)。 所以我很难在android上翻译文本。 任何人都可以帮我在android上做这个工作吗? 只是我已经在java中使用它,但我无法在Android上运行它。 我已经尝试过使用asynctask,但无济于事,没有翻译出来。 或者我刚刚做了一个错误的asyc任务? 应用程序的界面是这样的: 它只有一个简单的文本字段,其翻译应该在另一个文本字段中输出。 翻译是从韩语到英语。 Github项目文件在这里 https://github.com/iamjoshuabcxvii/MSTranslateAPIforAndroid Android代码是这样的。 import android.os.AsyncTask; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; import org.apache.commons.io.IOUtils; import java.net.URL; import java.net.URLEncoder; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.net.ssl.HttpsURLConnection; public class MainActivity extends AppCompatActivity { //MS Translator Key is in here public static String key = “”; private […]

如何简单检查Azure AD的用户名和密码是否正确

我想检查提供的用户名(microsoft azure domain uername)和密码是否正确。 我不希望返回任何令牌,而只是检查Azure AD用户凭据是否正确。 目前,我已经浏览了许多关于azure的博客和文档,并且已经看到了许多oauth2资助流程。 但那些我无法使用,因为它需要完成某些配置 任何人都可以请帮助我 我在服务器端使用Java 如果我的问题需要更多细节,请告诉我

Azure网站上的Tomcat 8

我可以看到Azure目前仅支持Java 7和Tomcat 7或Jetty 9.1。 至于系统的开发,客户正在考虑将Azure作为托管Java应用程序的选项。 该应用程序将使用Java 8编写。是否有人知道Microsoft是否有将Tomcat服务器更新为Tomcat 8的计划? 亚马逊去年11月已经有了这个,所以我认为微软不会等待太长时间。 有谁知道微软是否有任何“正式”升级计划,所以我不需要为网络应用购买整个VM? (或者使用Java 7)

GET文件的私有blob存储url的格式。 Rest API

微软表示,获取Blob只是一个普通的http get https://myaccount.blob.core.windows.net/mycontainer/myblob 。 但是,当我有一个帐户+共享密钥时,如何格式化字符串? 我知道有一个Azure SDK,但我正在为现有的java ee系统创建一个“附加组件”,并且无法在Azure中运行,因此我使用的是REST Api。 这是我到目前为止所尝试的: String account = “myaccount”; String key = “243fedfsdf23f4f”; String protocol = “http”; String storageConnectionString = String.format(“DefaultEndpointsProtocol=%s;AccountName=%s;AccountKey=%s”, protocol, account, key); System.out.println(storageConnectionString); URL url = new URL(“https://mysite.azureweb.com/myfile.txt”); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); if (conn.getResponseCode() != 200) { throw new IOException(conn.getResponseMessage()); } // Buffer the result into a […]

如何在windows azure上部署java应用程序

嗨,我是一名计算机科学专业的三年级学生,我已经在netbeans上用java创建了我的第三年项目,现在我想将它部署到一个带有windows azure的虚拟机上。 这一点的意思是,我希望能够在连接到互联网的任何计算机上使用此应用程序,只需访问云,而无需每次都安装程序(类似于如何在Steam上玩任何游戏)在任何电脑上)。 现在的问题是,是否有可能,如果是这样,我该如何做到这一点,提前谢谢