|
79 | 79 | },
|
80 | 80 | "outputs": [],
|
81 | 81 | "source": [
|
| 82 | + "declare @response nvarchar(max);\n", |
82 | 83 | "declare @payload nvarchar(max) = (select * from (values('Hello from Azure SQL!', sysdatetime())) payload([message], [timestamp])for json auto, without_array_wrapper)\n",
|
83 |
| - "declare @response nvarchar(max), @url nvarchar(max), @headers nvarchar(1000);\n", |
84 |
| - "declare @len int = len(@payload)\n", |
85 |
| - "\n", |
86 |
| - "-- Create the File\n", |
87 |
| - "set @url = 'https://blobby.blob.core.windows.net/myblobs/test-me-from-azure-sql.json'\n", |
88 |
| - "set @headers = json_object(\n", |
89 |
| - " 'x-ms-type': 'file',\n", |
90 |
| - " 'x-ms-content-length': cast(@len as varchar(9)),\n", |
91 |
| - " 'Accept': 'application/xml')\n", |
| 84 | + "declare @url nvarchar(max) = 'https://blobby.blob.core.windows.net/myblobs/test-me-from-azure-sql.json'\n", |
92 | 85 | "exec sp_invoke_external_rest_endpoint\n",
|
93 | 86 | " @url = @url,\n",
|
94 | 87 | " @method = 'PUT',\n",
|
95 |
| - " @headers = @headers,\n", |
| 88 | + " @headers = '{\"x-ms-blob-type\": \"BlockBlob\", \"Content-Type\":\"application/json\", \"Accept\":\"application/xml\"}',\n", |
| 89 | + " @payload = @payload,\n", |
96 | 90 | " @credential = [filestore],\n",
|
97 | 91 | " @response = @response output\n",
|
98 |
| - "select cast(@response as xml);\n", |
99 |
| - "\n", |
100 |
| - "-- Add text to the File\n", |
101 |
| - "set @headers = json_object(\n", |
102 |
| - " 'x-ms-range': 'bytes=0-' + cast(@len-1 as varchar(9)),\n", |
103 |
| - " 'x-ms-write': 'update',\n", |
104 |
| - " 'Accept': 'application/xml');\n", |
105 |
| - "set @url = 'https://blobby.blob.core.windows.net/myblobs/test-me-from-azure-sql.json'\n", |
106 |
| - "set @url += '?comp=range'\n", |
| 92 | + "select cast(@response as xml)\n", |
| 93 | + "go\n", |
| 94 | + "\n", |
| 95 | + "declare @response nvarchar(max);\n", |
| 96 | + "declare @url nvarchar(max) = 'https://blobby.blob.core.windows.net/myblobs/test-me-from-azure-sql.json'\n", |
107 | 97 | "exec sp_invoke_external_rest_endpoint\n",
|
108 | 98 | " @url = @url,\n",
|
109 |
| - " @method = 'PUT',\n", |
110 |
| - " @headers = @headers,\n", |
111 |
| - " @payload = @payload,\n", |
| 99 | + " @headers = '{\"Accept\":\"application/xml\"}',\n", |
112 | 100 | " @credential = [filestore],\n",
|
| 101 | + " @method = 'GET',\n", |
113 | 102 | " @response = @response output\n",
|
114 | 103 | "select cast(@response as xml)\n",
|
115 | 104 | "go"
|
|
0 commit comments